Re: [NSCoder versionForClassName] gives the current version?
Re: [NSCoder versionForClassName] gives the current version?
- Subject: Re: [NSCoder versionForClassName] gives the current version?
- From: Will Mason <email@hidden>
- Date: Wed, 9 Nov 2005 09:58:01 -0800 (PST)
If your "coder" is an instance of a encoding class, like NSArchiver or NSKeyedArchiver, then versionForClassName: will return the version of the class as it exists in the system. Only if your "coder" is an instance of a decoding class, like NSUnarchiver or NSKeyedUnarchiver, will it give you the version of the class that exists in the archive.
Also, I believe that the class' version will only be read from the archive as needed. It doesn't cache all the class versions at the beginning. Therefore, if your class hasn't yet been encountered in the archive during decoding, then you will get back the version of the class in the system, since there's not yet any data on the version of the class in the archive.
Cheers,
Will
----- Original Message ----
From: Jonathan del Strother <email@hidden>
To: Cocoa Dev <email@hidden>
Sent: Wed Nov 9 09:37:10 2005
Subject: [NSCoder versionForClassName] gives the current version?
I'm decoding a object using initWithCoder:, and checking the version
number of the stored object using versionForClassName:
It appears to be giving me the version number of the existing class,
rather than the version number of the stored class.
eg, if I do the following :
unsigned versionA = [coder versionForClassName:@"Preset"]; //returns 2.
[Preset setVersion:3];
unsigned versionB = [coder versionForClassName:@"Preset"]; //returns 3
Surely this isn't right? Isn't the point of versionForClassName: to
return the version of the stored object, so you can upgrade old
versions?
Jon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden