iphone - xcode counting JSON items -


i need count number of items (post) in json response,

2012-06-04 14:09:57.872 horitable[72261:11903] json : { posts =     (             {         post =             {             eventdate = "2012-03-31";             eventid = 2;             eventimage = "http://hernandoz.local/~hernandoz/kopict/02_31march2012.jpg";             eventinfo = "02 event";             eventname = "xplosion 02";         };     },             {         post =             {             eventdate = "2012-07-07";             eventid = 3;             eventimage = "http://hernandoz.local/~hernandoz/kopict/greg_vs_turner.jpg";             eventinfo = "02 event";             eventname = "xplosion 02";         };     },             {         post =             {             eventdate = "2012-04-29";             eventid = 4;             eventimage = "http://hernandoz.local/~hernandoz/kopict/ko_itclub_apr_2012.jpg";             eventinfo = "ko east london interclub";             eventname = "ko interclub";         };     } ); 

}

i know there 3 events (post), code using

 [[afnetworkactivityindicatormanager sharedmanager] decrementactivitycount];     nslog(@"json : %@", json); //get json response      // 6.1 - load json internal variable     jsonresponse = json;     // 6.2 - number of shows (post)     int shows = 0;     (nsdictionary* day in jsonresponse) {         shows += [[day objectforkey:@"posts"] count];          nslog(@"count : %d",shows);     } 

i error , don't understand why .

-[__nscfstring objectforkey:]: unrecognized selector sent instance 0x76986f0 

can please me out . thanks

try

nslog(@"response members= %@",responsestring); nsarray *array = [(nsdictionary*)[responsestring jsonvalue] objectforkey:@"posts"]; nslog(@"count value= %d",[array count]);     

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -