I have a class Persistent
, which needs to be archivable, but can change its name. NSKeyedArchiver provides +setClassName:
method to use custom class name during archiving and unarchiving. Can I perform class-name mapping in +load
method? Are there any gotchas?
@interface Persistent : NSObject <NSCoding>
@end
@implementation
+ (void)load {
[NSKeyedArchiver setClassName:@"class" forClass:self];
}
...
@end