Skip to content

Instantly share code, notes, and snippets.

@tolmasky
Created March 20, 2009 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolmasky/82369 to your computer and use it in GitHub Desktop.
Save tolmasky/82369 to your computer and use it in GitHub Desktop.
@implementation Shape : CPObject
{
CGRect mRect;
CPColor mColor;
}
- (void)encodeWithCoder:(CPCoder)aCoder
{
[aCoder encodeRect:mRect forKey:"rect"];
[aCoder encodeObject:mColor forKey:"color"];
}
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super init];
if (self)
{
mRect = [aCoder decodeRectForKey:"rect"];
mColor = [aCoder decodeObjectForKey:"color"];
}
return self;
}
@end
// Later on
data = [CPKeyedArchiver archivedDataWithRootObject:shapesArray]
// to decode
shapesArray = [CPKeyedUnarchiver data]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment