Hi Quincey, Thanks for you help. I am trying to pass the class reference around for drag and drop, I think i'll try your idea of converting the pointer to a number,
Cheers, Billy. On 14 May 2010, at 10:34, Quincey Morris wrote: > On May 14, 2010, at 02:13, Billy Flatman wrote: > >> 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"]; >> } > > NSValue doesn't support encoding for this sort of value: > > > http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Archiving/Tasks/codingctypes.html > > What are you really trying to do? > > If you're trying to have something persist across uses of your application, > it makes no sense to archive the class object pointer. Archive the class name > instead (via NSStringFromClass). > > If you're just trying to pass the class pointer around within the application > (like for dragging or putting something on a private pasteboard), you could > probably do it by casting the pointer to a number for encoding, and cast it > back to a pointer on decoding, but you're likely still far better off > archiving the class name instead. > > > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/b.flatman%40googlemail.com > > This email sent to b.flat...@googlemail.com Billy Flatman b.flat...@googlemail.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com