I'm implementing my own keyed NSCoder
subclass and decoding is failing for an NSString.
If I do something like the following:
MyUnarchiver *aDecoder = [[MyUnarchiver alloc] initWithData:someArchivedData];
NSString *aString = [[NSString alloc] initWithCoder:aDecoder];
Then the following "uncaught exception" is thrown:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'NSString cannot decode class version 12345'
Where 12345 is coming from this method in MyUnarchiver
, I presume:
-(NSInteger)versionForClassName:(NSString *)className
{
return 12345;
}
Similarly, if we throw a nil
NSCoder
at NSString
's initWithCoder:
then we get the same error as above, but the version number is 0.
I suspect it might have to do with the fact that I have no idea what I should be implementing in the versionForClassName:
method. Even from the Archives and Serializations: Subclassing NSCoder reference I'm unable to glean much on this.