Reputation: 1
I want to do some stuff from the appDelegate in Xcode. One of these things are to change a UILabel.
ViewController *viewController = [[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:@"id"];
viewController.label.text = @"heeej";
I was told this would do the trick. Doesn't work. Label doesn't change. Does anyone know what the problem is?
Upvotes: 0
Views: 506
Reputation: 14063
There are several problems:
id
as an identifier for anything in Objective-C is a bad idea because this is used as an object type.Edit: You don't need a reference to change a property in the view controller. Use notifications to update the label. The system sends a notification with the name UIApplicationWillEnterForgroundNotification' (see [here][1]). Add the view controller as an observer to the
[NSNotificationCenter defaultCenter]` for this name and react on the notification. Read the Apple documentation if you don't know what I am talking about.
Upvotes: 1