Object-C-Foundation-set

无序集合 哈希表

NSSet *colors=[NSSet setWithObjects:@@"yellow",@"red",@"blue",@"black",nil];

NSArray *array=[colors allObjects];

NSString *obj = [colors anyObject];

枚举器

NSEnumerator *numerator=[colors objectEnumerator];

for(id obj in numerator){

     NSLog(@"%@",obj);

}

NSSet colors2=[NSSet setWithObjects:@"yellow",nil];

if([colors intersectsSet:colors2]){}判断两个set是否有相同的东西

还有 isSubsetOfSet 判断是否是子集

 

NSmutableSet常用方法

addObject

removeObject

removeAllobjects

unionSet合并两个集合

minusSet 减法操作

NSMutableSet *set1=[NSMutableSet setWithObjects:@"yellow",@"red",nil];

NSMutableSet *set1=[NSMutableSet setWithObjects:@"yellow",nil];

 

posted @ 2015-06-08 11:19  来自大山深处的菜鸟  阅读(139)  评论(0编辑  收藏  举报