1.set // 集
例子
Person * p1 = [[Person alloc] initWithName:@"啊寿" sex:@"男" age:30];
Person * p2 = [[Person alloc] initWithName:@"阿福" sex:@"男" age:30];
Person * p3 = [[Person alloc] initWithName:@"啊幸" sex:@"男" age:25];
Person * p4 = [[Person alloc] initWithName:@"啊吉" sex:@"男" age:25];
Person * p5 = [[Person alloc] initWithName:@"阿运" sex:@"男" age:25];
Person * p6 = [[Person alloc] initWithName:@"阿帅" sex:@"男" age:25];
2. setWithObjects // 创建集并添加元素
+ (instancetype)setWithObjects:(id)firstObj // Creates and returns a set containing the objects in a given argument list.
例子:
NSLog(@"set = %@", set);
3.anyObject //从集中随机得到一个元素
@property(nonatomic, readonly) id anyObject //One of the objects in the hash table. (read-only)
例子
NSSet * set = [NSSet setWithObjects:p, p1, p2, p3, p4, p5, p6, nil];
NSLog(@"set = %@", set);
4.NSMutableSet //可变的集合