Sorry the basic question, but this bugs me for a while now.
I create a details view from a UITable and try to dynamically set its labels, but they are not updating:
Did you @synthesize your myLabel property in myViewController.m? You should be able to do something like:
tmpVC.myLabel.text = tmpObj.myTitle;
That's because the controller's view is lazily created only when accessed. Pushing the controller accesses the view.
Alternatively, if you add a line to access the view property, it will work too:
myViewController *tmpVC = [[myViewController alloc] initWithNibName:@"NIBfile" bundle:nil];
tmpVC.view; // Force view creation
[tmpVC.myLabel setText:tmpObj.myTitle]; // The debugger shows the text: myTitle = "myText"
NSLog(@"%@", tmpVC.myLabel); // NSLog will display "myText"
[self.navigationController pushViewController:tmpVC animated:YES];
Is it not because your NSLog is trying to print out the actual label object. Should you not have
NSLog(@"%@", tmpVC.myLabel.text);
In Response to the added information: Your other issue would appear to be that you have linked an NSString to your label. You have to link it to a UILabel. So where you declare your myLabel var, change it to UILabel *myLabel, and the same for any matching property.
Not sure but I think this is what's going on:
When the view is pushed, the controller loads the view from the nib and hooks up the actions and outlets. Before this, the outlets are not connected, so tmpVC.myLabel is nil.
If you want to be sure, you could put a breakpoint in viewDidLoad of tmpVC to see when the view is loaded.
If tmpVC.myLabel is NULL, that probably indicates that you have not made the necessary connection in Interface Builder from the UILabel to your myLabel instance variable.