您的位置:首页 > 移动开发 > Objective-C

Object-C-Foundation-set

2015-06-08 11:19 429 查看
无序集合 哈希表

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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: