Problem with -[NSKeyedArchiver setClassName:forClass:]
Problem with -[NSKeyedArchiver setClassName:forClass:]
- Subject: Problem with -[NSKeyedArchiver setClassName:forClass:]
- From: "Ben Kennedy" <email@hidden>
- Date: Mon, 18 Oct 2004 14:16:57 -0400
- Organization: Zygoat Creative Technical Services
Hi folks,
I have an <NSCoding> class which is archived as part of my app's data
file. Working on a new version of the app, this class (ZDBPatternEvent)
is now deprecated but I want to retain it for legacy compatibility. In
my project I have globally renamed it as ZDBOldPatternEvent.
During app startup, I do the following:
[NSKeyedUnarchiver setClass:[ZDBOldPatternEvent class] forClassName:
@"ZDBPatternEvent"];
in order to load legacy archives. This works as expected.
I also, however, I want to do the reverse; that is, archive
ZDBOldPatternEvent as "ZDBPatternEvent" so that older versions of my app
will read it correctly. So far as I can tell I should be able to do:
[NSKeyedArchiver setClassName:@"ZDBPatternEvent" forClass:
[ZDBOldPatternEvent class]];
...however, my app crashes with EXC_BAD_ACCESS somewhere within
encodeWithCoder: as soon as an instance of ZDBOldPatternEvent is being
encoded.
I've searched archives but there appears to be no mentions of
setClassName:forClass: that I've found. I've also tried the instance
version of this method (vs. the class version), and the results are the
same. Removing this call altogether (so that it is written as
"ZDBOldPatternEvent") works properly without a crash.
Can anyone suggest where the problem lies?
(Obviously, I could just keep the class named as ZDBPatternEvent, but in
the interests of sensible code management I don't want to.)
-ben
--
Ben Kennedy, chief magician
zygoat creative technical services
613-228-3392 | 1-866-466-4628
http://www.zygoat.ca
_______________________________________________
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