NSPredicate check for kind of object class

user500 picture user500 · Nov 9, 2011 · Viewed 11.4k times · Source

I have an array of UIView objects. I want to call - (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate on this array to get array of MyCustomView objects.

How to code predicate with "isKindOf:"?

Answer

Jef picture Jef · Nov 9, 2011

Try (depracated)

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

Or

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