【发布时间】:2011-11-16 02:45:13
【问题描述】:
我有这段代码,但不知道我做错了什么。正如您在下面的代码中看到的,我有一个名为 shifts.plist 的 plist 文件,它位于我的 supporting files 文件夹中。这是我的 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,得到以下结果。所以文件就在那里
我的解析出错了。
谢谢,
山姆
【问题讨论】:
-
尝试使用代码删除空格和符号:{ } , = ;
-
此代码有两个可能的问题:1) 在您的 plist
Name中使用大写 N,而在objectForKey:中使用小 n 2) 您尝试调用objectAtIndex从字典中检索到的对象。由于您已经获得了从字典返回的字符串对象,因此您不需要再调用objectAtIndex:。 -
谢谢,但它仍然返回 null。
标签: ios uitableview plist data-management