NSMutableSet 集合成员是无序的。对对象进行枚举所得到对象的顺序不能保证相同。向集合中添加相同对象时只会保留一个副本。和其它集合类一样添加移除对象都会分别收到retain和release消息。
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSMutableSet *fruits = [NSMutableSet setWithCapacity:2];
[fruits addObject:@"Apple"];
[fruits addObject:@"Orange"];
//从复添加只记录一条
[fruits addObject:@"Apple"];
NSLog(@"%@", fruits);
[pool drain];
return 0;
}