iphone - Populate Table View with an Array of Dictionaries -
i'm new iphone app development , i'm attempting create app uses json parse data webservice.
i've been able array of dictionaries i'm trying populate 2 different table views with. first table view use data has id of 1 , second use data has id of 2. need cell text equal each name of every dictionary has id of 1, i'll use other data in dictionary detail views. array looks this:
( { "name" = name; "email" = email; "id" = 1; }, { "name" = name2; "email" = email2; "id" = 1; }, { "name" = name; "email" = email; "id" = 2; }, { "name" = name2; "email" = email2; "id" = 2; } ) is there way create new array names have id of 1 can use populate table view?
thanks, appreciated.
untested on fly code, easiest solution build 2 separate arrays, like:
nsmutablearray* firstarray = [nsmutablearray array]; nsmutablearray* secondarray = [nsmutablearray array]; (nsdictionary* d in myarray) { if ([[d objectforkey:@"id"] isequaltostring:@"1"]) { [firstarray addobject:d]; } else { [secondarray addobject:d]; } } then can store 2 arrays , access them in table view delegate/datasource methods.
Comments
Post a Comment