Reputation: 1269
there are two view controllers with an embedded navigation controller. the 1st one has a table view. the second one, named "AfterTableViewController" has a label in it.
I wanna be able to set the label, in the prepareForSegue
method which is in the 1st view controller implementation file.
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
AfterTableViewController *afc = (AfterTableViewController*) segue.destinationViewController;
afc.title = @"the title"; // this works
afc.theLabel.text = @"hello"; // this doesn't work
}
how should I set the label?
Upvotes: 1
Views: 1696
Reputation: 474
Seeing as you are only trying to set the text value of the label, it would be best to create an other NSString property for this UILabel's text in your AfterTableViewController and then use it when constructing theLabel.
Upvotes: 2
Reputation: 173562
You have to make sure to add theLabel
as a (synthesized) property within the AfterTableViewController
for this to work.
Upvotes: 0