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:"?
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:"?
Try (depracated)
[NSPredicate predicateWithFormat: @"className == %@", [someObject className]]
Or
[NSPredicate predicateWithFormat: @"class == %@", [someObject class]]
I got errors using Jef's method. This worked for me, though.
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"self isKindOfClass: %@", class];
For anyone interested, here is the Swift version of Jef's Method:
NSPredicate(format: "className = %@", String(describing: MyCustomView.self))
How about using -className
as your key?
NSPredicate* foo = [NSPredicate predicateWithFormat: @"className == %@", @"MyCustomView"];