views:

295

answers:

2

I have NSMutableDictionary object say obj. When I write it to the disk using [obj writeToFile:filename atomically:YES] , the file does not get written to the disk. But the same set of statements work for a smaller mutable dictionary.

The first obj is (nonatomic, retain) property object of a class. The second smaller obj is a temporary local variable.

A: 

This should work. Have you checked that obj isn't nil by some accident?

Georg
NSLOG(obj) seems to work :(
Amal
And filename exists too?
Georg
+1  A: 

But the same set of statements work for a smaller mutable dictionary.

That sets off a warning bell. Namely, when you are attempting to write the large dictionary to disk, what is in it? If you are using any of NSDictionary's file writing methods, they will only work with dictionaries that only contain instances of the classes blessed for use in property lists.

That is, if you have random other classes in there, the dictionary will not be written. Doesn't matter of the classes support NSCoding or not.

If you need to persist a dictionary with non-property list classes, you'll either need to use NSCoding or, more likely better, use Core Data.

bbum