条件nsarray计数

Dar*_*ren 2 xcode cocoa-touch objective-c nsmutablearray nsarray

我想要计算子数组满足条件的数组.我以为我能做到这一点,但我做不到.

NSLog(@"%d",[[_sections enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
            [[obj objectAtIndex:4] isEqualToString:@"1"];
        }] count]);
Run Code Online (Sandbox Code Playgroud)

bbu*_*bum 8

enumerateObjectsUsingBlock:没有任何回报.我敢打赌代码甚至不会编译(并且,正如你的评论所说,自动完成不起作用 - 它不应该).

使用NSArray indexesOfObjectsPassingTest: 并获取count结果NSIndexSet.

记录在这里.