陣列包含字典 去重

weixin_34253539發表於2017-12-07

NSMutableArray *categoryArray = [[NSMutableArray alloc] init];

NSMutableArray *belongArray = [[NSMutableArray alloc] init];

for (int i = 0; i<_dataArray.count; i++){

NSString *string = _dataArray[i][@"belong"];

if (![categoryArray containsObject:string]){

[categoryArray addObject:string];

[belongArray addObject:[_dataArray objectAtIndex:i]];

}

}


相關文章