ios - Assigning a dictionary to a variable -
when check self.weatherdata, nothing though there data in "data". here function:
- (void)handlenetworkresponse:(nsdata *)mydata { //nsmutabledictionary *data = [nsmutabledictionary dictionary]; nsmutabledictionary *data = [[nsmutabledictionary alloc] init]; // we'll parse our data using nsjsonserialization id myjson = [nsjsonserialization jsonobjectwithdata:mydata options:nsjsonreadingmutablecontainers error:nil]; // typecast array , list contents nsdictionary *jsonarray = (nsdictionary *)myjson; // take @ elements in array (id element in jsonarray) { id key = [element description]; id innerarr = [jsonarray objectforkey:key]; nsdictionary *inner = (nsdictionary *)innerarr; if ([inner conformstoprotocol:@protocol(nsfastenumeration)]) { for(id ele in inner) { id innerkey = [ele description]; [data setobject:[[inner valueforkey:innerkey] description] forkey:[ele description]]; } } else { [data setobject:[inner description] forkey:[element description]]; } } nslog([data description]); self.weatherdata = data; }
however when check self.weatherdata, nothing though there data in "data".
issue data isn't there when assign variable asynchronous method :d fixed adding delegate call back
Comments
Post a Comment