我不断收到以下错误:
saving dictionary error Property list invalid for format (property lists cannot contain objects of type 'CFNull')
当我尝试使用以下代码保存文件时:
- (BOOL)saveDictionary:(NSDictionary *)dict toFile:(NSString *)file {
BOOL success = NO;
if (file == nil || dict == nil) return NO;
NSString *errorStr = nil;
NSData *plistData = [NSPropertyListSerialization dataFromPropertyList:dict
format:NSPropertyListBinaryFormat_v1_0
errorDescription:&errorStr];
if (errorStr) {
// Darn.
NSLog(@"saving dictionary error %@", errorStr);
[errorStr release];
} else {
// [plistData writeToFile:file atomically:YES];
// (ankit): Changing this to NO for speed.
success = [plistData writeToFile:file atomically:NO];
}
return success;
}
知道为什么吗?