Reputation: 697
In my application: didFinishLaunchingWithOptions: method, I set some non-optional dictionaries and save them to the standard user defaults. However, the dictionaries are not available when the tableview loads, and my app breaks down.
Also, I have a println(1) that does not get run in the application: didFinishLaunchingWithOptions: method before the tableView is loaded and the app crashes.
I am just wondering when the application: didFinishLaunchingWithOptions: is run relative to when the first view is initialized.
Upvotes: 0
Views: 1315
Reputation: 9687
application: didFinishLaunchingWithOptions: gets called first. It seems as though you save dictionaries in defaults and then try to read them very soon after. If you read the docs for NSUserDefaults, it is not guaranteed that the defaults have saved when you set objects, for efficiency purposes. You should call defaults.synchronize() to ensure that they save after you set the dictionaries if you plan on relying on them to save right when you set them.
Upvotes: 1