Re: encoding vended objects
Re: encoding vended objects
- Subject: Re: encoding vended objects
- From: Jacob Engstrand <email@hidden>
- Date: Wed, 29 Aug 2007 11:38:53 +0200
On 29 aug 2007, at 05.47, Brian Chin wrote:
This seems simple enough. However, my app crashes when trying to
send this
object through a NSPortCoder.
I assume that the members (distance, duration, dateFor) are objects
that can be encoded/decoded, like NSString, NSNumber, etc...?
You need to try something similar to the following. It is also a lot
faster than keyed coding. (Make sure you encode and decode the
members in the same order.)
- (void)encodeWithCoder:(NSCoder *)encoder
{
[encoder encodeObject:distance];
[encoder encodeObject:duration];
[encoder encodeObject:dateFor];
}
- (id)initWithCoder:(NSCoder *)decoder
{
self = [super initWithCoder: decoder];
if (nil != self) {
distance = [decoder decodeObject];
duration = [decoder decodeObject];
dateFor = [decoder decodeObject];
}
return self;
}
jak
_______________________________________________
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