Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sujithkrishnan

macrumors 6502
Original poster
Hi all,

I am working out with teh method writeToFile: atomically: with the NSArray and NSDictionary.

However i tried adding some simple strings to dictionary as key and values.
The dictionary got saved successfully.

However i added some custom object (say itemObject of type Item) to dictionary with some unique NSString as key.

But writeToFile: is returning me NO

The Item class implemented encodeWithCoder and decodeWithCoder methods to encode/decode the properties.

I can succesfully persist the same Object using NSKeyedArchiver.

Why its not working with writeToFile: ? ?

Thanks
 
Have you checked the Apple documents for the NSArray and/or NSDictionary class reference?

"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."
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.