两个数组,获取其中一个数组中不在两个数组元素交集的元素

方法1

NSArray *arr1 = @[@1,@2,@3,@4,@5,@6,@7,@8];
NSArray *arr2 = @[@4,@5,@6,@7,@8,@9,@10,@11];
NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:1];
for (int i=0; i if (![arr2 containsObject:arr1[i]]) {
[mArray addObject:arr1[i]];
}
}

方法2

NSArray *arr1 = @[@1,@2,@3,@4,@5,@6,@7,@8];
NSArray *arr2 = @[@4,@5,@6,@7,@8,@9,@10,@11];
NSMutableArray *mArray = [NSMutableArray arrayWithArray:arr1];
[mArray removeObjectsInArray:arr2];

你可能感兴趣的:(两个数组,获取其中一个数组中不在两个数组元素交集的元素)