Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment