objective c - Cocoa Bindings - NSTableView - Swapping Values -


is nsvaluetransform subclass choice displaying core data attributes ui views displaying:

  1. a number string (0,1,2,3,etc) string such (pending, completed, frozen, in progress, etc)
  2. 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:

enter image description here

here want displayed instead, without changing values in core data:

enter image description here

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

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

gradle error "Cannot convert the provided notation to a File or URI" -