我有两个NSArray
包含整数值。我想从两个数组中获取公共值,为此我正在使用NSMutableSet
.
这是我的代码
`
NSMutableSet *set1 = [NSMutableSet setWithArray:array1]];
NSMutableSet *set2 = [NSMutableSet setWithArray:array2];
if (![set1 isEqualToSet:set2])
{
[set2 intersectSet:set1];
NSArray *commonArray = [set2 allObjects];
}
`
这是数组 `array1 ( 2, 3 ) 中的值
array2 ( 2, 3 )
and values in
NSMutableSet` 是
` set1 {( 2, 3 )}
设置2 {( 2, 3 )} `
根据条件和值,代码不会执行if()
条件内的行。但是这里的if()
条件返回错误的值。
也[set2 intersectSet:set1];
返回set2
为空。
这段代码有什么问题。
请帮我解决这个问题。