I have an NSMutableArray created storing song names and artists. I am trying to convert this array to NSData format so that I can save it to a text file. When attempting to do so, the output I get is unreadable:
bplist00ÔghX$versionX$objectsY$archiverT$top † ¯$ !")-./3459:;?@AEFGKLMQRSWXY]^_cU$nullÒ R$0V$class€€#Ò ZNS.objectsª€€€ € ...etc.
The code I'm using to convert from an NSMutableArray to NSData is:
NSFileManager *fm;
NSData *dataCache = [NSKeyedArchiver archivedDataWithRootObject:myList];
fm = [NSFileManager defaultManager];
if ([fm createFileAtPath:@"/users/nicholasvogler/desktop/Mysongs.txt" contents:dataCache attributes:nil] == NO)
{
NSLog (@"Could not create data file");
return 1;
}
All objects in the array are NSStrings and I've added the following method for the strings and the array:
-(void) encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject: songname];
[encoder encodeObject: artist];
}