ios - Split a single NSMutableArray into two so that I can set each in each of the section in UITableView -
i want use multiple sections feature uitableview
. have single nsmutablearray
consists of data in dictionary format. in dictionary there key has values '0' , '1'. want create 2 separate nsmutablearray
out of can assign them accordingly in different sections.
for example :
if (indexpath.section==0) { nsdictionary *data = [roomlist1 objectatindex:indexpath.row]; } else { nsdictionary *data = [roomlist2 objectatindex:indexpath.row]; }
assuming value in dictionary set like:
nsmutablearray *firstarray = [nsmutablearray new]; nsmutablearray *secondarray = [nsmutablearray new]; (nsdictionary *dictionary in yourarray) { if ([dictionary objectforkey:@"yourvalue"] isequaltostring: @"0") { [firstarray addobject:dictionary]; } else if ([dictionary objectforkey:@"yourvalue"]isequaltostring: @"1") { [secondarray addobject:dictionary]; } }
Comments
Post a Comment