I’m trying to write an NSArray of NSDictionaries to the documents folder. I’m using
BOOL fileWritten = [favoritesArray writeToFile:fullFileName atomically:NO];
if (fileWritten == NO) {
NSLog(@"Writing favoritesFileFailed");
}
The above keeps returning NO. Any idea why this wouldn’t be writing? What’s really strange is that this same code was working a few days ago. I read something stating that writeToFile can’t handle complex objects. Would NSDictionary be an object writeToFile can’t save?
Writing the
NSDictionaryitself to a file is not a problem, but the objects it holds may be.By using the simple property list-related I/O methods, you can write out objects of classes
NSArray,NSDictionary,NSData,NSString,NSNumber,NSDate, and any combination thereof (e.g., arrays of dictionaries).Also, it won’t overwrite an existing file, so have you checked that?