set集合_变长

//set可变集合
//便利初始化函数分配大小
NSMutableSet *mutableSet1 = [[NSMutableSet alloc] initWithCapacity:3];
NSMutableSet *mutableSet2 = [NSMutableSet setWithCapacity:3];

Z

//添加元素

[mutableSet1 addObject:@"aaa"];
[mutableSet1 addObject:@"BBB"];
[mutableSet1 addObject:@"bbb"];

NSLog(@"%@",mutableSet1);

 

//删除元素
[mutableSet1 removeObject:@"ccc"];

NSLog(@"%@",mutableSet1);

 

//遍历Set
NSArray *setArray = [mutableSet1 allObjects];
NSLog(@"%@",mutableSet1);
 
原文地址:https://www.cnblogs.com/kluan/p/4819447.html