ham*_*ene 32
在NSSet的方法中很容易发现:
- (NSSet *) setByAddingObjectsFromSet:(NSSet*) other;
Run Code Online (Sandbox Code Playgroud)
如果其中一个集合是a,NSMutableSet
则可以使用union操作,如下例所示:
// Create / Get the sets
NSMutableSet *firstSet = [NSMutableSet setWithArray:@[@"1", @"2"]];
NSSet *secondSet = [NSSet setWithArray:@[@"3",@"4"]];
// Add missing values from the second set to the first set
[firstSet unionSet:secondSet];
Run Code Online (Sandbox Code Playgroud)