daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
Top