大家好,我从一个plist中加载了一个表,我正在尝试转到下一个tableviewController,并使用PLIST键加载下一个内容,与所选行的名称相同。这是我的代码,但是当我执行segue时,我从plist的第一个对象获取内容,因为所有的键都找不到错误。
#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];
}发布于 2016-03-13 12:21:43
Plist字典有字符串值的键。根据您实现它的方式(例如,如果它的行号仅为行号),您可以这样访问它:
plistList = [[NSDictionary dictionaryWithContentsOfURL:url]valueForKey:[@([path row]) stringValue];发布于 2016-03-13 13:18:59
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];https://stackoverflow.com/questions/35970124
复制相似问题