我有这段代码,无法弄清楚我在做什么错。如您在下面的代码中看到的,我在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"]

08-07 17:23
查看更多