如何从NSDictionary数组中检查bool值

Hur*_*rkS 1 boolean objective-c nsdictionary nsarray ios

我通过一个循环NSArrayNSDictionaries,我那么想使用的一个值在NSDictionary这类型的BOOL一个,如果statment ..但我有一些麻烦的事情了.

这就是我的for loop样子

for(NSDictionary *dict in arrayOfDictionaries)
    {
        NSNumber *boolCheck = [dict objectForKey:@"ISREADY"]; // isReady is the bool value which is either 0 or 1

        if (boolCheck == [NSNumber numberWithBool:YES]) {

//...
   }
}
Run Code Online (Sandbox Code Playgroud)

发生的事情是它循环遍历我的数组,但从未满足我的if语句的条件,即使我100%确定数组中有这种类型的值...并且很多就此而言.

任何帮助,将不胜感激.

Tom*_*ton 7

假设NSNumber包含BOOL,请尝试

if ([boolCheck boolValue]) {
    ....
}
Run Code Online (Sandbox Code Playgroud)