0

in my Xcode project I have a button, that does two things.

First: call an IBAction Second: go to another view (segue)

In the action linked to the button I set a variable to YES (global var), but in the viewDidLoad method in the linked view, its still NO. Its YES in viewDidAppear though. I wonder why the action is not called first. Can I change that? I'd prefer to use the viewDidLoad method, since it seems to load quicker.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Philip
  • 1,068
  • 3
  • 12
  • 21

1 Answers1

0

You can use the prepareForSegue method to pass whatever data to the destination view before the segue assigned to the button is performed. This data will be available in the destination view viewDidLoad

McDaddy
  • 144
  • 6
  • thank you! but i just realized, the viewDidLoad method only is loaded once, right? its not appropriate for me anyway. – Philip Mar 06 '14 at 01:06
  • `ViewDidLoad` is called once when the controller is loaded. If the controller is unloaded and loaded again, it will be called again. – McDaddy Mar 06 '14 at 01:18
  • makes sense, but when is it loaded again? when i close and restart the app? – Philip Mar 06 '14 at 01:47