在这里用的是正则匹配
NSArray *arrayBase = @[@1, @2, @3, @4, @5, @6];
NSArray *arrayCom = @[@1, @4, @7, @11, @8, @"hh"];
NSArray *data1Array = [arrayBase filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT (SELF IN %@)",arrayCom]];//筛选arrayBase中不含有arrayCom的
NSArray *data2Array = [arrayCom filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"NOT (SELF IN %@)",arrayBase]];//筛选arrayCom中不含有arrayBase的
NSMutableArray *totolArray = [NSMutableArray new];
[totolArray addObjectsFromArray:data1Array];
[totolArray addObjectsFromArray:data2Array];
NSLog(@"不同的元素 %@",totolArray);
网友评论