zac*_*zac 0 arrays if-statement objective-c ios
我有两个数组,数组A有4个元素,数组B有10个元素.如何将这两个数组进行比较,以确定数组A是否包含数组B中包含的值
这是代码.
for(int i = 0; i <= deepsightSig.count; i++){
for(int p = 0; p <= feeds.count; i++){
if(feeds[i] == deepsightSig[i]){
badIPCount++;
}
else
goodIPCount++;
}
}
Run Code Online (Sandbox Code Playgroud)
小智 8
NSMutableSet* set1 = [NSMutableSet setWithArray:array1];
NSMutableSet* set2 = [NSMutableSet setWithArray:array2];
[set1 intersectSet:set2]; //this will give you only the obejcts that are in both sets
NSArray* result = [set1 allObjects];
Run Code Online (Sandbox Code Playgroud)
如果result.count大于1,则表示数组A具有数组B中的值.
| 归档时间: |
|
| 查看次数: |
1445 次 |
| 最近记录: |