Hello Everyone i have loaded a table from a plist and i am trying to go to next tableviewController and load the next content with PLIST KEY the same name as the selected row. This is my code but when i am doing the segue i am getting the content from 1st object of the plist for all the keys cant find the error
#pragma mark - Navigation
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"ChannelList"]){
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
ChannelsViewController *cvc =segue.destinationViewController;
cvc.currentChannel = [countriesArray objectAtIndex: indexPath.row];
}
Plist dictionary has keys that are string value. Depending on how you implemented it (for example, if its row number only) you could access it like this:
plistList = [[NSDictionary dictionaryWithContentsOfURL:url]valueForKey:[@([path row]) stringValue];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"OSMainStoryBoard" bundle: nil];
YourClassName *controller = [storyboard instantiateViewControllerWithIdentifier:@"YourClassName"];
NSIndexPath *path = [self.tableView indexPathForSelectedRow];
NSURL *url = [[NSBundle mainBundle] URLForResource:@"MyPlist" withExtension:@"plist"];
controller.plistList = [[NSDictionary dictionaryWithContentsOfURL:url]valueForKey:path];
controller.plistArray = plistList.allKeys;
[self.navigationController pushViewController:controller animated:YES];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.