[SwiftUI] CustomNavigation에서 .append() 및 removeLast()로 이동하기


[SwiftUI] CustomNavigation에서 .append() 및 removeLast()로 이동하기

`removeLast()` 함수는 Swift의 배열(Array) 타입에서 사용되며, 배열의 마지막 요소를 제거합니다. 배열이 비어있지 않다면, 가장 마지막에 있는 요소를 배열에서 제거하고 그 값을 반환합니다. 만약 배열이 비어 있을 때 이 함수를 호출하면 런타임 에러가 발생합니다. // PathType.swift import Foundation enum PathType: Hashable { case homeView case todoView case memoView(isCreateMode: Bool, memo: Memo?) } ///////// // Path.swift import Foundation class PathModel: ObservableObject { @Published var paths: [PathType] init(paths: [PathType] = []) { self.paths = paths } } var body: some View { ZStack { VStack ...


#append #customNavigation #removeLast

원문링크 : [SwiftUI] CustomNavigation에서 .append() 및 removeLast()로 이동하기