ios - How can I handle this Array object? (Objective-C) -
first have nsdictionary
. nsurlrequest
, load dictionary json information request.
nsdictionary *json =[nsjsonserialization jsonobjectwithdata:response options:kniloptions error:&error];
this dictionary has 2 keys 2 values. 1 key = (_nscfstring) "games" (value: (_nscfarray*)) , other 1 "id"(of player). because want recent games [json objectforkey:@"games"]
. nsarray
10 objects. first object listed below. how can label champion (from championid) player played or game type played? because in 1 object.
how can split array information?
i appreciate every help. thank time.
'nslogged' [ objectatindex:0] { championid = 102; createdate = 1394092919791; fellowplayers = ( { championid = 37; summonerid = 23497430; teamid = 200; }, { championid = 81; summonerid = 29757887; teamid = 200; }, { championid = 75; summonerid = 37419112; teamid = 100; }, { championid = 64; summonerid = 22985242; teamid = 100; }, { championid = 412; summonerid = 50506867; teamid = 100; }, { championid = 77; summonerid = 30770067; teamid = 200; }, { championid = 61; summonerid = 38231891; teamid = 200; }, { championid = 110; summonerid = 46318423; teamid = 100; }, { championid = 238; summonerid = 51117008; teamid = 100; } ); gameid = 1359691076; gamemode = classic; gametype = "matched_game"; invalid = 0; level = 30; mapid = 1; spell1 = 4; spell2 = 14; stats = { assists = 3; championskilled = 4; goldearned = 12280; goldspent = 11945; item0 = 1055; item1 = 3153; item2 = 3075; item3 = 3143; item4 = 3047; item5 = 1011; item6 = 3340; killingsprees = 2; largestkillingspree = 2; largestmultikill = 1; level = 17; magicdamagedealtplayer = 68999; magicdamagedealttochampions = 5146; magicdamagetaken = 2044; minionskilled = 226; neutralminionskilled = 13; neutralminionskilledenemyjungle = 12; neutralminionskilledyourjungle = 1; numdeaths = 1; physicaldamagedealtplayer = 71900; physicaldamagedealttochampions = 2948; physicaldamagetaken = 19358; team = 200; timeplayed = 1814; totaldamagedealt = 141513; totaldamagedealttochampions = 8708; totaldamagetaken = 21469; totalheal = 3243; totaltimecrowdcontroldealt = 276; totalunitshealed = 1; truedamagedealtplayer = 614; truedamagedealttochampions = 614; truedamagetaken = 66; turretskilled = 4; wardplaced = 8; win = 1; }; subtype = "cap_5x5"; teamid = 200; }
update 1: self.getrecentgames returns nsdictionary (and not getter self.recentgames)
self.recentgames = [[nsdictionary alloc] initwithdictionary:self.getrecentgames]; nsdictionary *dict = [self.recentgames objectforkey:@"games"]; //now dict have 10 object dict type: __nscfarray
update 2: finished! time. after checked class object array have show, nsdictionary. easy , find out. answers helped much!
assuming structure show in question, following:
nsdictionary *game = [games objectatindex:0]; // did nsnumber *championid = [game objectforkey:@"championid"];
edit based on comment:
like user hot licks mentioned, if such exception, assuming have dictionary instead end array. in case, you'd same twice:
nsarray *game = [games objectatindex:0]; // did nsnumber *championid = [game objectatindex:indexofchampionid];
although doubt if latter looking for. so, you'll have check part import data.
Comments
Post a Comment