ios - How to parse the data of JSON response in Objective-C? -
i got json output in link
i extracted id in output. (i.e)
419023188150340,
419023228150336,
419023278150331,
419023318150327,
419044998148159,
419045028148156
using following code
[[dict objectforkey:@"data"]valueforkey:@"id"]; dict has total output displayed on link
i displayed in tableview.
if once tap cell in tableview. table should fetch value of "picture" , display in console(nslog).
i used following code response , store in dictionary(here dict)
- (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response { responsedata=nil; idarray=nil; responsedata=[[nsmutabledata alloc]init]; idarray=[[nsmutablearray alloc]init]; dict=[[nsdictionary alloc]init]; } - (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data { [responsedata appenddata:data]; } - (void)connectiondidfinishloading:(nsurlconnection *)connection { dict=[nsjsonserialization jsonobjectwithdata:responsedata options:0 error:null]; [idarray addobjectsfromarray:[[dict objectforkey:@"data"]valueforkey:@"id"]]; [tablevw reloaddata]; } can 1 tell me how this.
you doing wrong. first nsarray of ids , have loop on extract each id. try -
nsarray *fbids = [dict objectforkey:@"data"]; for(nsdictionary *fbid in fbids) { nslog("fb id: %@", [fbid valueforkey:@"id"]); } once extract correct facebook_id, can use http://graph.facebook.com/419023188150340/picture picture. hope helps...
Comments
Post a Comment