Objective C: Fetch value from dictionary -
my "savedata" dictionary looks this:
{ adresser = { "completed_status" = { finished = 4; total = 5; }; ... }
and "dorder" dictionary looks this
{ id = 1924; name = adresser; order = 0; }
and snippet of code
nsdictionary * savedata = [self dbreadformdata:_objectid]; (nsdictionary * dorder in dictformsections[@"order"]) { nsstring * segname = dorder[@"name"]; nslog(@"finished: %@", savedata[segname][@"completed_status"][@"finished"]); nslog(@"total: %@", savedata[segname][@"completed_status"][@"total"]); nsstring * vfinished = [savedata objectforkey:savedata[segname][@"completed_status"][@"finished"]]; nsstring * vtotal = [savedata objectforkey:savedata[segname][@"completed_status"][@"total"]]; nsstring * ssection = [nsstring stringwithformat:@"%@ - %@ / %@", segname, vfinished, vtotal]; [rx insertsegmentwithtitle:ssection atindex:rx.numberofsegments animated:no]; }
the nslog's return correct values. (4 , 5) nsstrings nil.
what doing wrong?
thank you!
as mentioned @arc676, have :
nslog(@"finished: %@", savedata[segname][@"completed_status"][@"finished"]);
and
nsstring * vfinished = [savedata objectforkey:savedata[segname][@"completed_status"][@"finished"]];
however, not same. shouldn't vfinished like:
nsstring* vfinished = savedata[segname][@"completed_status"][@"finished"];
Comments
Post a Comment