方法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<arr1.count; 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];