gpt4 book ai didi

IOS 如何将索引中的字典数组项与另一个 NSarray 索引项进行比较

转载 作者:行者123 更新时间:2023-11-29 01:27:19 26 4
gpt4 key购买 nike

我有一个名为“feeds”的词典项目。在提要中,我有一个名为“SignatureNumber”的 key 。这个键里面包含一个数组项的列表。

当我注销时,它看起来像这样。

Final signature : (
{
SignatureNumber = 7075274256;
}
)

现在,我有另一个 NSarray 调用“信息”,其中包含项目列表。我想比较这两个数组的索引内的项目。

目前,这是我的代码。

   for (int i=0; i <information.count; i++) {
for (NSDictionary *feed in feeds) {

if ([feed[@"SignatureNumber"] containsObject:[information objectAtIndex:i]]) {
badIPCount++;
}else{
goodIPCount++;
}
}
}

错误是我的代码没有将“提要”中的项目与“信息”进行比较。为什么?请帮我调整我的代码。谢谢。

最佳答案

for (NSDictionary * dict in feeds) {

for (NSNumber * number in deepsightSig) {

long idFeed = [dict[@"SignatureNumber"] longValue]; /// if your id is too large, using NSString instead.
long idSig = [number longValue]; /// like NSString = [number stringValue];

if (idFeed == idSig) { /// if using NSString, it should be: "if ([idFeed isEqualToString:idSig])"
badIPCount++;
}
else {
goodIPCount++;
}
}
}

关于IOS 如何将索引中的字典数组项与另一个 NSarray 索引项进行比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33863458/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com