i have nsdictionary fill json. looks great, , partially working me. setting property of class of type nsstring equal value key, oddly enough sets property equal object object being string value need.
the dictionary (printed description):
miscinfo: <__nsarrayi 0x7494ab0>( { abbreviation = dr; dateinactive = ""; description = drowsiness; forqueue = 2430; isadditive = 0; isreserved = 1; misccodetypestr = avr; pluraldescription = ""; reserveddescription = drowsiness; }
i setting on property so:
self.reactionname = [miscinfo valueforkeypath:@"description"];
which produces:
i've tried casting nsstring such as:
self.reactionname = (nsstring*)[allergenadversereaction valueforkeypath:@"description"];
but nothing gives. doing wrong?
miscinfo
array containing dictionary,
self.reactionname = [[miscinfo objectatindex:0] objectforkey:@"description"];
would give result expect. or, using modern array , dictionary subscripting syntax:
self.reactionname = miscinfo[0][@"description"];
remark: in code
self.reactionname = [miscinfo valueforkeypath:@"description"];
valueforkeypath
applied each element of array, , array values returned. see in xcode debugger window.
this "feature" can useful, in general (as hot licks commented above) objectforkey
right method value dictionary. and
self.reactionname = [miscinfo objectforkey:@"description"];
throws descriptive runtime exception if miscinfo
not dictionary expected.
Comments
Post a Comment