iphone - key values from an NSDictionary formatting with "()" -
i'm trying pull 2 values dictionary, values i'm getting have "()" around them. ideas causing this?
here serveroutput:
{"rows":[{"userid":"1","location":"beach"}]}
dictionary after json:
{ rows = ( { location = beach; userid = 1; } ); }
this i'm getting:
location : ( beach ) user id : ( 1 )
both userid , location key values have "()". here code. lot.
nsstring *serveroutput= [[nsstring alloc] initwithdata:dataurl encoding:nsutf8stringencoding]; if(serveroutput > 1){ sbjson *jsonff = [[sbjson new] autorelease]; nserror *error3 = nil; nsdictionary *useriddict= [jsonff objectwithstring:serveroutput error:&error3]; nslog(@"useriddict: %@",useriddict); idreturn = [[useriddict valueforkey:@"rows"] valueforkey:@"userid"]; locationreturn = [[useriddict valueforkey:@"rows"] valueforkey:@"location"]; nslog(@" user id : %@", idreturn); nslog(@" location : %@", locationreturn);
just clarify going on. when parsing json {} gets returned dictionary , [] gets retured array. have useriddict
nsdictionary
containing parsed data.
'useriddict' has 1 key rows
returns nsarray
.
nsarray *useridarray = [useriddict objectforkey:@"rows"];
our useridarray
has 1 element, nsdictionary
nsdictionary *dict = [useridarray objectatindex:0];
this dict
contains 2 keys: location
, userid
nsstring *location = [dict objectforkey:@"location"]; nsinteger userid = [[dict objectforkey:@"userid"] intvalue];
Comments
Post a Comment