不知道为什么我的.plist看起来像这样,当viwed作为源代码,而不是像XML文件。从plist返回项目数
{
authorLastName = Doe;
authorFirstName = Jane;
imageFilePath = "NoImage.png";
title = "Account Test 1";
year = 2009;
},
{
authorLastName = Doe;
authorFirstName = John;
imageFilePath = "NoImage.png";
title = "Account Test 2";
year = 2009;
}
是对的.plist应该作为源代码查看时的样子吗?
第二,任何人都可以举一个例子来说明如何重新计算每个字典中的最后一个项目的数量吗?我已经研究过这么多个小时了,我把我的头发拉出来,因为我无法继续前进,直到我得到正确的答案!我尝试的每种方法都返回0.我在iPhone编程方面真的很新,所以我希望能得到任何帮助!也许是阅读plist的完整例子吗?
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString * documentsDirectory = [paths objectAtIndex:0]; 的NSString * myPlistPath = [documentsDirectory \t \t \t \t \t \t stringByAppendingPathComponent:@ “Accounts.plist”]; NSArray * arr = [NSArray arrayWithContentsOfFile:myPlistPath]; int count = 0; (NSDictionary * dict in arr){ \t count + = dict.count; } return count; ////////////////////////// 上述线端模拟器,错误: 程序接收到的信号:“EXC_BAD_ACCESS”。 – WrightsCS 2009-09-11 04:46:55