Guest User

Untitled

a guest
Apr 16th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. var WidgetJSON = @"WidgetJSON";
  2. @implementation Screen (CPCoding)
  3. - (id)initWithCoder:(CPCoder)aCoder
  4. {
  5. // This code will only work when this screen is in the main window - that should
  6. // always be the case
  7. var jsonObject = [aCoder decodeObjectForKey:WidgetJSON];
  8. return [[CPClassFromString(jsonObject.widgetType) alloc] initFromJSON:jsonObject];
  9. }
  10.  
  11. - (void)encodeWithCoder:(CPCoder)aCoder
  12. {
  13. [aCoder encodeObject:[[self toJSON] objectFromJSON] forKey:WidgetJSON];
  14. }
  15.  
  16. @end
Add Comment
Please, Sign In to add comment