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);
 
posted @ 2015-09-18 15:52  Nicat  阅读(272)  评论(0编辑  收藏  举报