Essentially I would like to print the following "hello" message only once when the view appears only the first time when the app first loads. The ViewController can be shown again when a tab in a tab controller triggers it, but it should not print the message after the very first time. Going back to the ViewController should not trigger this "hello" to print.
The following is what I have already tired, but it does not seem to work?
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if self.isBeingPresented || self.isMovingToParent {
print("hello")
}
}
The most stable way is
var once = true
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if once {
print("hello")
once = false
}
}
As self.isBeingPresented || self.isMovingToParen
can give unexpected results according to where you use it
I appreciate your help, I have a separate question regarding textField, can you please have a look? stackoverflow.com/questions/56876794/…