gpt4 book ai didi

ios - Objective-C 检查带整数的数组是否包含整数

转载 作者:可可西里 更新时间:2023-11-01 03:02:15 24 4
gpt4 key购买 nike

<分区>

伙计们,我正在努力做到以下几点。我有一个名为“specialLevels”的数组 (NSArray),该数组如下所示:

specialLevels = @[@2, @4, @6, @9];

这应该是一个整数数组。我还得到了 int 'currentLevel'(基本 int 无对象)。

我想检查 currentLevel 是否在 specialLevels 数组中。我知道方法“containsObject”存在,但这在我的情况下不起作用。

在这种情况下你们会建议做什么?

所以我是这么想的,但我觉得有点奇怪:

if ([specialLevels containsObject:[NSNumber numberWithInt:currentLevel]]) {
// other code in here
}

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