I assume you have a label set up in interface builder, and hooked up to an outlet in your view controller.
I suspect you're trying to set myLabel.text = blah before the view is actually loaded, and therefore before myLabel is still set to nil. Any message sent to nil is ignored, so calling nil.text = blah does nothing. Try debugging or logging myLabe to see if it is nil.
This happens because views are not actually loaded until someone asks for myController.view - that's when the view is built and the outlets are connected.
I typically load the data when the app starts, pass the data into a property of the view controller, and then set the labels / fields in viewWillAppear. I'd love to hear what others do, though.
I assume you have a label set up in interface builder, and hooked up to an outlet in your view controller.
I suspect you're trying to set myLabel.text = blah before the view is actually loaded, and therefore before myLabel is still set to nil. Any message sent to nil is ignored, so calling nil.text = blah does nothing. Try debugging or logging myLabe to see if it is nil.
This happens because views are not actually loaded until someone asks for myController.view - that's when the view is built and the outlets are connected.
I typically load the data when the app starts, pass the data into a property of the view controller, and then set the labels / fields in viewWillAppear. I'd love to hear what others do, though.
ok. thanks, i have this app more than halfway built, and i wouldnt want to transfer my labels into a viewWillAppear, unless its not that hard of course.
Is there a function to set exp to [[NSUserDefaults standardDefaults] integerWithKey:@"key"]; before the view loads, like a beforeViewLoads method?
No problem, I should have been more clear. This is better: "The view (and outlet objects) are not loaded yet when viewDidLoad, awakeFromNib, and applicationDidBecomeActive are called. You can't set the text of a label until viewWillAppear or viewDidAppear."