Search code examples
iphonensfilemanager

archiveRootObject:toFile: file looks like gibberish


I'm trying to write my NSMutableArray to a text file. I looked at the data with NSLog before I write it, and it's in the format I want

String \t integer \t integer \t integer \r\n
String \t integer \t integer \t integer \r\n
... (50 lines like this)
String \t integer \t integer \t integer \r\n

I write the file by:

[NSKeyedArchiver archiveRootObject:myMutableArray toFile:newPath];

When I look at the file on disk however, it is a bunch of gibberish. Am I doing something wrong here? Or am I understanding how archiveRootObject:toFile: works incorrectly? Thanks.


Solution

  • You can't examine the file directly as it's written in a binary format. You'll have to load it back in order to read it.

    See the discussion in the documentation.