How To Write JSON Response Into Property List Using Objective C?

338 Views Asked by At

I have create JSON data store into propertylist, Its was worked very well. Today below code is not working data everything coming from JSON but the problem is data not storing anything, showing null values.

My Code :

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);
}

Facing below 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

There are 0 best solutions below