【发布时间】:2012-01-02 12:33:43
【问题描述】:
我的问题是当我在NSMutableArray 中读取 plist 文件的内容时总是返回 null
NSString *resourceDocPath = [[NSString alloc] initWithString:[[NSBundle mainBundle]bundlePath]] ;
// Create the new dictionary that will be inserted into the plist.
NSMutableDictionary *nameDictionary = [NSMutableDictionary dictionary];
[nameDictionary setValue:@"walid" forKey:@"id"];
[nameDictionary setValue:@"555 W 1st St" forKey:@"lien"];
NSString *r = [NSString stringWithFormat:@"%@/download.plist", resourceDocPath];
NSLog(@"%@",r);
// Open the plist from the filesystem.
NSMutableArray *plist = [NSMutableArray arrayWithContentsOfFile:r];
NSLog(@"%@",plist);
if (plist == NULL)
{
plist = [NSMutableArray array];
}
[plist addObject:nameDictionary];
NSLog(@"%@",plist);
[plist writeToFile:r atomically:YES];
当我查看 plist 文件时,我发现我只插入了一个数据
你能帮帮我吗?
【问题讨论】:
标签: objective-c nsmutablearray plist nsdictionary