我有这段代码,无法弄清楚我在做什么错。如您在下面的代码中看到的,我在shifts.plist
文件夹中有一个名为supporting files
的plist文件。这是我的plist结构。
NSString *path = [[NSBundle mainBundle] pathForResource:@"shifts" ofType:@"plist"];
dictionary = [[NSMutableDictionary alloc]initWithContentsOfFile:path];
cell.textLabel.text = [secondTableInfo objectAtIndex:indexPath.row];
NSLog(@"%@",[[dictionary objectForKey:@"name"]objectAtIndex:0]);
我最终希望阅读
name
条目并用它们填充UITableView
。我使用
NSLog
输出dictionary
,得到了以下内容。所以文件就在那里我错了的解析。
谢谢,
山姆
最佳答案
看来您需要先调用objectAtIndex:
,然后再调用objectForKey:
例如:
[[dictionary objectAtIndex:0] objectForKey:@"Name"]