Encode a 'Class' type using NSValue
Encode a 'Class' type using NSValue
- Subject: Encode a 'Class' type using NSValue
- From: Billy Flatman <email@hidden>
- Date: Fri, 14 May 2010 10:13:11 +0100
Hi all,
I'm trying to encode a 'Class' type parameter in an class implementing the NSCoding interface, but I keep getting the error 'cannot encode (void *) value: <c0860200 01000000>'.
Here's an extract the class I'm encoding:
@interface IFNode : NSObject <NSCoding> {
Class persistentObjectClass;
}
@property (nonatomic, retain) Class persistentObjectClass;
@end
@implementation IFNode
@synthesize persistentObjectClass;
- (void) encodeWithCoder: (NSCoder *) encoder {
NSValue* value = [[NSValue valueWithPointer:persistentObjectClass] retain];
[encoder encodeObject:value forKey:@"Class"];
}
- (id) initWithCoder: (NSCoder *) decoder {
[((NSValue*)[decoder decodeObjectForKey:@"Class"]) getValue:persistentObjectClass];
return self;
}
@end
Any help greatly appreciated.
Cheers,
Billy Flatman
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden