API之NSSet的常见用法

/*

NSSet *set1 = [[NSSet alloc] initWithObjects:@"  ",@"性别不明", @"非地球物种", nil];

NSArray *array = [set1 allObjects];

for (int i = 0; i < [array count]; i++) {

NSLog(@"%@", [array objectAtIndex:i]);

}


//是否包含对象

if ([set1 containsObject:@"name"]) {

NSLog(@"yes");

} else {

NSLog(@"no");

}

NSSet *set2 = [[NSSet alloc] initWithObjects:@"",@"性别不明", @"地球生物", nil];


//判断集合1和集合2是否碰撞

if ([set1 intersectsSet:set2]) {

NSLog(@"yes");

} else {

NSLog(@"no");

}

if ([set1 isEqualToSet:set2]) {

NSLog(@"yes");

} else {

NSLog(@"no");

}


//集合2是否是集合1子集

if ([set1 isSubsetOfSet:set2]) {

NSLog(@"yes");

} else {

NSLog(@"no");

}



*/

NSMutableSet *mSet1= [[NSMutableSet allocinitWithObjects:@"aaa", @"sss", @"ddd", @"dfg",

@"fgfd", nil];

NSMutableSet *mSet2= [[NSMutableSet allocinitWithObjects:@"sss", @"dfg", @"drf", nil];


//数组1 减去数组2

// - (void)minusSet:(NSSet *)otherSet;

// [mSet1 minusSet:mSet2];

// NSLog(@"%@", mSet1);


//数组拼接

// - (void)unionSet:(NSSet *)otherSet;

[mSet1 unionSet:mSet2];

NSLog(@"%@", mSet1);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值