I loaded my pList into a table view controller that segues to a view controller. I can’t figure out how to load the data corresponding to the cell tapped into a label on this view controller. The plist is an NSDictionary, by the way.
In viewDidLoad of the table view controller I have:
NSString *myFile = [[NSBundle mainBundle]
pathForResource:@"recipes" ofType:@"plist"];
recipes = [[NSDictionary alloc] initWithContentsOfFile:myFile];
courseKeys = [recipes allKeys];
I am not sure how to tell the label that the name of the recipe chosen was X so you display the ingredients for X.
Thanks for the help!
Kevin
Don’t forget – a
UITableViewis a way to display your data. Once a user selects a row within a UITableView, you get notified of this via yourUITableViewDelegatemethod (specificallydidSelectRowAtIndexPath). You can use the indexPath to grab whatever data you need from whatever data structure you’re working with (in your case,NSDictionary) and pass it on to whatever controller you are displaying next by implementing theprepareForSegueuemethod correctly. I would suggest defining a property in that next UIViewController and assigning it the data to be passed on inprepareForSegueue. I would however pay some thought as to wether you wish to pass a direct reference to the data or maybe a deep copy of it – it really depends on what you’re trying to accomplish in that VC.