Created
March 20, 2009 14:03
-
-
Save tolmasky/82369 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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