objective c - Cocoa Bindings - NSTableView - Swapping Values -
is nsvaluetransform subclass choice displaying core data attributes ui views displaying:
- a number string (0,1,2,3,etc) string such (pending, completed, frozen, in progress, etc)
- a number string (0,1) app-based image (red.png if 0, green.png if 1)
here's core data displays 2 attributes, timer , status:
here want displayed instead, without changing values in core data:
if not use nsvaluetransformer, in other way possible?
i not want see data permanently converted, benefit of less data stored in core data , better ui view items.
i have tried modify attributes in managed object class (with out kvo notification) no luck.
yes, nsvaluetransformer
subclasses work fine purpose.
you can add read-only computed properties managed object class, , should work, too. properties can added category in controller code, if don't make sense part of model code.
for example:
+ (nsset*) keypathsforvaluesaffectingstatusdisplayname { return [nsset setwithobject:@"status"]; } - (nsstring*) statusdisplayname { nsstring* status = self.status; if ([status isequaltostring:@"0"]) return @"pending"; else if ([status isequaltostring:@"1"]) return @"completed"; // ... }
the +keypathsforvaluesaffectingstatusdisplayname
method lets kvo , bindings know when status
changes, new statusdisplayname
property. see docs +keypathsforvaluesaffectingvalueforkey:
learn how works.
Comments
Post a Comment