Encoding a Custom Object which has a CALayer instance Variable (newbie Question)
Encoding a Custom Object which has a CALayer instance Variable (newbie Question)
- Subject: Encoding a Custom Object which has a CALayer instance Variable (newbie Question)
- From: Gustavo Pizano <email@hidden>
- Date: Fri, 12 Dec 2008 21:43:30 +0100
Hello. I want to send the following an object in a drag-n-drop
operation, so I need to transform it to a NSData
so I have this object
@interface Ship : NSObject <NSCoding> {
int size;
int impacts;
ShipLocation * location;
CALayer * shipImageLayer;
}
now, I was reading that I must implement <NSCoding> and implement the
-(id)initWithCoder:(NSCoder *)coder and -(void)encodeWithCoder:
(NSCoder *)coder methods, so far so good,
then I can use the encodeObject: forKey method of NSCoder class. so I
will have the following
-(id)initWithCoder:(NSCoder *)coder
{
[coder encodeInt:size forKey:@"size"];
[coder encodeInt:impacts forKey:@"impacts"];
}
but after I dunno how to code the location and the shipImageLayer? I
guess ShipLocation should implement <NSCoding> also and encode its
attributes, but in shipLocation there is also a CALayer, so I still
have the question on how to do it with a CALayer.
I dunno if [NSKeyedArchiver
archivedDataWithRootObject:<#(id)rootObject#>] will do the trick. or....
thanks
gustavo
_______________________________________________
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