我必须在我的plist文件中修改存储在bundle中的BOOL值。我能够访问我必须修改的字典。从nslogging中我可以看到该字典用新的值,但问题是,当我检查的plist捆绑是不是被modified.any线索,它为什么不更新的plist修改一个plist不起作用
NSString* plistPath = nil;
NSFileManager* manager = [NSFileManager defaultManager];
if (plistPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"TopicsList.plist"])
{
if ([manager isWritableFileAtPath:plistPath])
{
NSMutableArray* dictarrays = [NSMutableArray arrayWithContentsOfFile:plistPath];
NSMutableDictionary *dict=[dictarrays objectAtIndex:indexPath.row];
NSLog(@"%@ ",dict);
[dict setObject:[NSNumber numberWithBool:YES] forKey:@"isPaid"];
NSLog(@"%@ ",dict);
[dict writeToFile:plistPath atomically:NO];
NSLog(@"%@ ",dict);
[manager setAttributes:[NSDictionary dictionaryWithObject:[NSDate date] forKey:NSFileModificationDate] ofItemAtPath:[[NSBundle mainBundle] bundlePath] error:&error];
}
}
和@Nayefc这样就意味着我应该在Xcode中删除我的plist的参考和保存的plist在我的项目文件夹? – sujith1406 2011-06-16 08:32:24
保留在那里。在应用程序启动时,将plist从您的包中复制到应用程序的Document文件夹(如果它尚不存在)。用相关的代码更新我的答案(应该在应用程序中去:didFinishLaunchingWithOptions: – lostInTransit 2011-06-16 10:09:56