Reputation: 2161
Hi i am trying to write an NSDictionary to a plist in the documents folder, but unable to write , i am using the writeToFile:atomically: method , which returns False. The complete code is
-(void)writeData:(NSDictionary *)dicResponseData
{
// get paths from root directory
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
// get documents path
NSString *documentsPath = [paths objectAtIndex:0];
// get the path to our Data/plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"Contractors.plist"];
[dicResponseData writeToFile:plistPath atomically: TRUE];
}
the dictionary contains 25 sub dictionaries in it .
Upvotes: 0
Views: 1509
Reputation: 28419
All objects in your dictionary have to be property list objects.
This method recursively validates that all the contained objects are property list objects (instances of NSData, NSDate, NSNumber, NSString, NSArray, or NSDictionary) before writing out the file, and returns NO if all the objects are not property list objects, since the resultant file would not be a valid property list.
Upvotes: 1