Created
September 15, 2009 07:41
-
-
Save saikat/187172 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
var WidgetJSON = @"WidgetJSON"; | |
@implementation Screen (CPCoding) | |
- (id)initWithCoder:(CPCoder)aCoder | |
{ | |
// This code will only work when this screen is in the main window - that should | |
// always be the case | |
var jsonObject = [aCoder decodeObjectForKey:WidgetJSON]; | |
return [[CPClassFromString(jsonObject.widgetType) alloc] initFromJSON:jsonObject]; | |
} | |
- (void)encodeWithCoder:(CPCoder)aCoder | |
{ | |
[aCoder encodeObject:[[self toJSON] objectFromJSON] forKey:WidgetJSON]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment