(i just start learning app development)
I start a new project on Xcode using SwiftUI and i am learning .OnAppear and .onDisappear
it work great but as soon i close the simulator by swinging up the simulator the .OnAppear and .onDisappear doesn’t work anymore i don’t know what is wrong
i appreciate any help
i have search the internet, youtube , even Ai didn’t help
should the OnAppear and .onDisappear behave like this or is there a settings that can run these function event if the app closed
this is an example code
import SwiftUI
struct ContentView: View {
@State private var CountUp: Int = 0
var body: some View {
Text("(CountUp)")
.onAppear {
CountUp += 1
}
}
}
#Preview {
ContentView()
}
once i close the simulator by swinging up the app and reopen it with in the simulator the .onAppear function don’t work anymore
MacMini is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.