gpt4 book ai didi

iphone - 寻找一种优雅的方法来检查字典中是否存在键

转载 作者:IT王子 更新时间:2023-10-29 08:13:48 27 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to check if an NSDictionary or NSMutableDictionary contains a key?

我可以从字典中获取键(字符串)数组,然后循环遍历它,将字符串与我要检查的键进行比较,看看该字典是否包含我要查找的键。

但是有没有更优雅的想检查key是否存在于字典中呢?

        NSArray * keys = [taglistDict allKeys];
for (NSString *key in keys)
{
// do string compare etc
}

-代码

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