【发布时间】:2011-06-16 07:57:10
【问题描述】:
我必须修改与捆绑包一起存储的 plist 文件中的 BOOL 值。我能够访问我必须修改的字典。从 nslogging 我可以看到字典已更新为新值,但问题是当我检查捆绑中的 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];
}
}
【问题讨论】:
标签: iphone objective-c ios plist