I need to set and store some NSUserDefaults data that can be used withing a View. This doesn't work using viewDidLoad.
Can this be done? What method could I use before viewDidLoad? What would you recommend?
There are a couple of methods on UIViewController
that will definitely get run before viewDidLoad
- which is the appropriate place for your code depends on your specific problem and architecture.
initWithNibName:bundle:
is called when the view controller is createdloadView
is the code that sets up the viewAnother option is to ensure that the defaults are set up by a different component, before your view controller is even initialised. That could be in the view controller of a preceding part of the workflow, or initialised by the application delegate.