diff --git a/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2.xcodeproj/project.pbxproj b/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2.xcodeproj/project.pbxproj index e1312e8..df511f7 100644 --- a/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2.xcodeproj/project.pbxproj +++ b/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2.xcodeproj/project.pbxproj @@ -16,6 +16,7 @@ AB206DD8290D52FA00EA4A65 /* MyLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DD7290D52FA00EA4A65 /* MyLabel.swift */; }; AB206DDA290D548A00EA4A65 /* MyNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DD9290D548A00EA4A65 /* MyNavigationView.swift */; }; AB206DDC290D55F300EA4A65 /* MyNavigationStack.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DDB290D55F300EA4A65 /* MyNavigationStack.swift */; }; + AB206DDE290D56F400EA4A65 /* MyAppear.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB206DDD290D56F400EA4A65 /* MyAppear.swift */; }; AB8CFF0E2907D6DC009C3479 /* Inflearn_SwiftUI_Lv2App.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB8CFF0D2907D6DC009C3479 /* Inflearn_SwiftUI_Lv2App.swift */; }; AB8CFF102907D6DC009C3479 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB8CFF0F2907D6DC009C3479 /* ContentView.swift */; }; AB8CFF122907D6DE009C3479 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB8CFF112907D6DE009C3479 /* Assets.xcassets */; }; @@ -35,6 +36,7 @@ AB206DD7290D52FA00EA4A65 /* MyLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyLabel.swift; sourceTree = ""; }; AB206DD9290D548A00EA4A65 /* MyNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyNavigationView.swift; sourceTree = ""; }; AB206DDB290D55F300EA4A65 /* MyNavigationStack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyNavigationStack.swift; sourceTree = ""; }; + AB206DDD290D56F400EA4A65 /* MyAppear.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyAppear.swift; sourceTree = ""; }; AB8CFF0A2907D6DC009C3479 /* Inflearn-SwiftUI-Lv2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Inflearn-SwiftUI-Lv2.app"; sourceTree = BUILT_PRODUCTS_DIR; }; AB8CFF0D2907D6DC009C3479 /* Inflearn_SwiftUI_Lv2App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Inflearn_SwiftUI_Lv2App.swift; sourceTree = ""; }; AB8CFF0F2907D6DC009C3479 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -91,6 +93,7 @@ AB206DD7290D52FA00EA4A65 /* MyLabel.swift */, AB206DD9290D548A00EA4A65 /* MyNavigationView.swift */, AB206DDB290D55F300EA4A65 /* MyNavigationStack.swift */, + AB206DDD290D56F400EA4A65 /* MyAppear.swift */, ); path = "Inflearn-SwiftUI-Lv2"; sourceTree = ""; @@ -173,6 +176,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + AB206DDE290D56F400EA4A65 /* MyAppear.swift in Sources */, AB8CFF1C2907D740009C3479 /* MyDarkColor.swift in Sources */, AB206DD6290D4F5C00EA4A65 /* MyProgress.swift in Sources */, AB206DD8290D52FA00EA4A65 /* MyLabel.swift in Sources */, diff --git a/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/Inflearn_SwiftUI_Lv2App.swift b/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/Inflearn_SwiftUI_Lv2App.swift index ec0d980..f224d12 100644 --- a/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/Inflearn_SwiftUI_Lv2App.swift +++ b/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/Inflearn_SwiftUI_Lv2App.swift @@ -11,7 +11,7 @@ import SwiftUI struct Inflearn_SwiftUI_Lv2App: App { var body: some Scene { WindowGroup { - ContentView() + MyAppear() } } } diff --git a/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/MyAppear.swift b/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/MyAppear.swift new file mode 100644 index 0000000..eadabec --- /dev/null +++ b/Inflearn-SwiftUI-Lv2/Inflearn-SwiftUI-Lv2/MyAppear.swift @@ -0,0 +1,67 @@ +// +// MyAppear.swift +// Inflearn-SwiftUI-Lv2 +// +// Created by 김민 on 2022/10/29. +// + +import SwiftUI + +struct MyAppear: View { + + @State var name: String = "No name" + @State var isPresented: Bool = false + + var body: some View { + + NavigationView { + NavigationLink("Test") { + Text("Sample") + .onAppear { + print("On Appear Sample") + } + .onDisappear { + print("On Disappear Sample") + } + } + } + .onAppear { + print("On Appear") + } + .onDisappear { + print("On Disappear") + } + +// VStack { +// Text(name) +// .onAppear { +// print("On Appear") +// } +// .onDisappear { +// print("On Disappear") +// } +// .sheet(isPresented: $isPresented) { +// Text("Modal") +// } +// +// Button { +// isPresented.toggle() +// } label: { +// Text("Change") +// .onAppear { +// print("On Appear Modal") +// } +// .onDisappear { +// print("On Disappear Modal") +// } +// } +// +// } + } +} + +struct MyAppear_Previews: PreviewProvider { + static var previews: some View { + MyAppear() + } +}