Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 518 Bytes

File metadata and controls

36 lines (25 loc) · 518 Bytes

#NSMutableSet

首先我们来初始化两个set

NSMutableSet *muSet = [NSMutableSet set];
NSSet *set = [NSSet setWithObjects:@"hello",@"world",@"ios", nil];

##增加

[muSet addObject:@"hello"];

##合并

[muSet unionSet:set];

##截取

[muSet addObject:@"asdf"];
// 此时 由于muSet中@"asdf"在set中不存在,所以自动删除
[muSet intersectSet:set];

##删除

NSSet *set1 = [NSSet setWithObjects:@"world",@"ios", nil];
[muSet minusSet:set1];