iOS 数组集合(交集,并集,差集,子集)
2021-11-11 本文已影响0人
zxb有缘
NSArray *array1 = @[@"11",@"22",@"33"];
NSArray *array2 = @[@"11",@"55",@"66"];
NSMutableSet *set1 = [NSMutableSet setWithArray:array1];
NSMutableSet *set2 = [NSMutableSet setWithArray:array2];
[set1 unionSet:set2]; //取并集后 set1中为11,22,33,55,66
[set1 intersectSet:set2]; //取交集后 set1中为11
[set1 minusSet:set2]; //取差集后 set1中为22,33,55,66