zots
Re-member
I have been trying to get my array of custom objects written to file. My subclass implements NSCoding's:
My code for calling the encode method and then writing the array is:
My tableView is able to read the data of the array and calling the encode method seems to work but when the array is written to file it is empty...
Code:
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeDataObject:[myString1 dataUsingEncoding:NSASCIIStringEncoding]];
[encoder encodeDataObject:[myString2 dataUsingEncoding:NSASCIIStringEncoding]];
}
Code:
[myNSCoder encodeObject:myObject];//create NSCoder for encodeWithCoder
[myObject encodeWithCoder:myNSCoder];//call NSCoding method in subclass
[myArray addObject:myObject];
[myArray writeToFile:path atomically:YES];