• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Encode a 'Class' type using NSValue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Encode a 'Class' type using NSValue
      • From: Quincey Morris <email@hidden>
  • Prev by Date: NSDateFormatter for a web app UTC format
  • Next by Date: TUTORIAL: Generating Unique ID Strings
  • Previous by thread: NSDateFormatter for a web app UTC format
  • Next by thread: Re: Encode a 'Class' type using NSValue
  • Index(es):
    • Date
    • Thread