相关疑难解决方法(0)

查找NSMutableArrays的交集

我有三个NSMutableArray包含根据不同的标准添加到列表中的名称.

这是我的数组伪代码:

NSMutableArray *array1 = [@"Jack", @"John", @"Daniel", @"Lisa"];
NSMutableArray *array2 = [@"Jack", @"Bryan", @"Barney", @"Lisa",@"Penelope",@"Angelica"];
NSMutableArray *array3 = [@"Jack", @"Jerome", @"Dan", @"Lindsay", @"Lisa"];
Run Code Online (Sandbox Code Playgroud)

我想找到第四个数组,其中包括这三个数组的交集.在这种情况下,例如它将是:

NSMutableArray *array4 = [@"Jack",@"Lisa"];
Run Code Online (Sandbox Code Playgroud)

因为所有三个阵列都有jack和lisa作为元素.有没有办法简单地这样做?

iphone intersection nsmutablearray

40
推荐指数
1
解决办法
2万
查看次数

NSPredicate两个NSNumber阵列

我在为搜索功能编写谓词时遇到了一些困难,并认为你需要帮助.所以基本上我有两个NSNumbers阵列.我希望我的谓词满足以下条件:

If a number's integerValue in array A matches any integerValue in array B.
Run Code Online (Sandbox Code Playgroud)

我不想为这个解决方案使用任何类型的循环.这是我到目前为止所拥有的

ANY integerValue == ANY //how do I pass the entire array here and ask for the integerValue of each member? 
Run Code Online (Sandbox Code Playgroud)

objective-c nspredicate ios

0
推荐指数
1
解决办法
973
查看次数