ios - Convert JSON feed to NSDictionary -


where json_category_data_url_string feed url, returns fine as:

[     {         "group":"for sale",         "code":"ssss"     },     {         "group":"for sale",         "category":"wanted",         "code":"swnt"     } ] 

i cannot seem nice nsdictionary (or nsarray) out of following code:

+ (nsdictionary *)downloadjson {  nsdictionary *json_string; nsstring *dataurl = [nsstring stringwithformat:@"%@", json_category_data_url_string]; nslog(@"%@",dataurl); nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:dataurl]];     nsdata *response = [nsurlconnection sendsynchronousrequest:request returningresponse:nil error:nil];  json_string = [[[nsstring alloc] initwithdata:response encoding:nsutf8stringencoding]autorelease]; nsdictionary *json_dict = (nsdictionary *)json_string; nslog(@"json_dict\n%@",json_dict);     nslog(@"json_string\n%@",json_string);  return json_string; } 

i've read many posts on this, not getting it.

with ios5 can use nsjsonserialization serializing json.

nsdictionary *dictionary = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; 

hope you.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -