ios - NSMutableData to NSDictionary returning null -
i'm writing program uses instagram api , i'm running issues nsmutabledata , nsdictionary.
since have make multiple calls api, decided create nsmutabledata object
, append smaller nsdata objects , turn whole thing nsdictionary.
however, after make second call nsmutabledata appenddata nsdata,
when turn nsmutabledata
nsdictionary
, dictionary returns null.
here's of code.
nsmutabledata *userdata = [[nsmutabledata alloc]init] nsdata *feed = [nsdata datawithcontentsofurl:[nsurl urlwithstring:[nsstring stringwithformat:@"https://api.instagram.com/v1/users/17636367/media/recent?access_token=%@",accesstoken]]]; [userdata appenddata:feed]; nsdata *moardata = [nsdata datawithcontentsofurl:[nsurl urlwithstring:[nsstring stringwithformat:@"https://api.instagram.com/v1/users/17636367/media/recent?access_token=%@&max_id=%@",accesstoken, maxid]]]; [userdata appenddata:moardata]; nsdictionary *dicttwo = [nsjsonserialization jsonobjectwithdata:userdata options:nsjsonreadingmutablecontainers error:nil]; nslog(@"%@",dicttwo);
dicttwo returns null. however, when make 1 call appenddata, dictionary isn't empty.
thanks.
when append 2 separate json responses not form json.
you can test final result see if json or not following link:
you need parse each query response separately , apply manipulation on data: (ex nsmutabledictionary, nsmutablearray etc).
Comments
Post a Comment