如何使用Objective C将JSON响应写入属性列表?

时间:2016-02-24 11:04:48

标签: objective-c json property-list

我已将JSON数据存储创建到propertylist,其工作得非常好。今天下面的代码不是来自JSON的所有数据,但问题是数据没有存储任何内容,显示空值。

我的代码:

NSArray *paths_watch = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = paths_watch.firstObject;
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"newplist.plist"];
NSError *writeError = nil;
NSDictionary *finalDict = @{@"Objects": objects};

//Here I am not getting data below line           
NSData *plistData = [NSPropertyListSerialization dataWithPropertyList:finalDict format:NSPropertyListXMLFormat_v1_0 options:NSPropertyListImmutable error:&writeError];

NSLog(@"DATA FOR PLIST : %@",plistData);

if(plistData) {
    [plistData writeToFile:plistPath atomically:YES];
} else {
NSLog(@"Error in saveData: %@", error);
}

面对以下错误:

Error Domain=NSCocoaErrorDomain Code=3851 "Property list invalid for format: 100 (property lists cannot contain objects of type 'CFNull')" UserInfo={NSDebugDescription=Property list invalid for format: 100 (property lists cannot contain objects of type 'CFNull')}

0 个答案:

没有答案