NSPredicate检查对象类的种类

我有一个UIView对象的数组。 我想在这个数组上调用- (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate来获取MyCustomView对象的数组。

如何用“isKindOf:”编码谓词?

尝试( depracated

 [NSPredicate predicateWithFormat: @"className == %@", [someObject className]] 

要么

 [NSPredicate predicateWithFormat: @"class == %@", [someObject class]] 

我用Jef的方法得到了错误。 这对我来说,虽然。

 NSPredicate *predicate = [NSPredicate predicateWithFormat: @"self isKindOfClass: %@", class]; 

来源: https : //stackoverflow.com/a/2556306/168594

如何使用-className作为你的钥匙?

 NSPredicate* foo = [NSPredicate predicateWithFormat: @"className == %@", @"MyCustomView"];