gpt4 book ai didi

ios - 字典比较数组

转载 作者:行者123 更新时间:2023-12-01 19:09:40 24 4
gpt4 key购买 nike

这是我的应用程序代码输出,这是我的字典值数组array1,array2的数组。

array1(
{
city = Glendale;
country = US;
st = AZ;
},
{
city = "Glendale Luke AFB";
country = US;
st = AZ;
},
{
city = Goodyear;
country = US;
st = AZ;
},
{
city = Phoenix;
country = US;
st = AZ;
}


array2(
{
cont = US;
cty = Glendale;
sta = AZ;
},
{
cont = US;
cty = Glendale;
sta = CA;
},
{
cont = US;
cty = Glendale;
sta = CO;
},
{
cont = US;
cty = Glendale;
sta = ID;
},
{
cont = US;
cty = Glendale;
sta = KY;
},
{
cont = US;
cty = Glendale;
sta = MA;
},
{
cont = US;
cty = Glendale;
sta = MS;
},
{
cont = US;
cty = Glendale;
sta = MO;
},
{
cont = US;
cty = Glendale;
sta = NY;
},
{
cont = US;
cty = Glendale;
sta = OH;
},
{
cont = US;
cty = Glendale;
sta = OR;
},
{
cont = US;
cty = Glendale;
sta = RI;
},
{
cont = US;
cty = Glendale;
sta = SC;
},
{
cont = US;
cty = Glendale;
sta = TX;
},
{
cont = US;
cty = Glendale;
sta = UT;
},
{
cont = US;
cty = Glendale;
sta = WI;
},
{
cont = ZW;
cty = Glendale;
sta = "";
}

如何比较两个匹配相同城市,州,国家的字典值数组。请问有人可以帮我解决这个问题吗?

最佳答案

尝试这样的事情:

for (id object1 in array1) 
{
for (id object2 in array2)
{
if ((object1.cty == object2.cty) &&
(object1.cont == object2.cont) &&
(object1. sta == object2.sta))
{
// do smth
}
}
}

请记住,如果您有NSString对象,则需要使用isEqualToString而不是“==”!

关于ios - 字典比较数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17235913/

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