iphone----NSMutableSet

来源:互联网 发布:如何修改路由器mac地址 编辑:程序博客网 时间:2024/04/26 01:20
NSMutableSet 集合成员是无序的。对对象进行枚举所得到对象的顺序不能保证相同。向集合中添加相同对象时只会保留一个副本。和其它集合类一样添加移除对象都会分别收到retain和release消息。
#import <Foundation/Foundation.h>int main (int argc, const char * argv[]){    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];    NSMutableSet *fruits = [NSMutableSet setWithCapacity:2];//设置NSMutableSet的容量为2    [fruits addObject:@"Apple"];    [fruits addObject:@"Orange"];        //从复添加只记录一条    [fruits addObject:@"Apple"];        NSLog(@"%@", fruits);    [pool drain];    return 0;}
原创粉丝点击