ios - Is it posible to conditionally disable NSValueTransformer for NSManagedObject attribute? -
specifically, have nsmanagedobject "statuscode" attribute set transformable, , reversible value transformer subclass covert nsstrings nsnumbers , vice versa. idea use value transformer receive json , string "status" key in json automatically maps nsnumber represents status code in nsmanagedobject. conversely if upload nsmanagedobject server, @ point status attribute transformed nsnumber string json.
so far good. but, if want able simple int out of nsmanagedobjec's status property, can , enums in code? is, i'd lie cover 3 cases:
mymanagedobject.status = [jsonresponse valueforkey:@"status"]
(should use transformer nsstring -> nsnumber)[jsonforupload setvalue:mymanagedobject.status forkey:@"status"]
(should use transformer nsnumber->nsstring)- from elsewhere in code, along lines of:
if(mymanagedobject.status & statusinprogress) ...
statusinprogress enum.
i'm thinking temporarily disable value transformer, have no idea if nsmanagedobject has reference it, or if should disable nsvaluetransformer class, apparently keeps table of registered transformers?
i know 3rd case [mymanagedobject.status intvalue]
, bitwise comparison, i'm wondering if there's way can have intvalue]
returned automagically, user of object's point of view.
any ideas?
why don't write 2 additional methods json transform , leave property integer? you'd have best both worlds.
Comments
Post a Comment