How do I return the entire set / array using NSPredicate?
Posted
by Prairiedogg
on Stack Overflow
See other posts from Stack Overflow
or by Prairiedogg
Published on 2010-03-29T03:41:30Z
Indexed on
2010/03/29
3:43 UTC
Read the original article
Hit count: 306
I'm building a carArray
and want to filter the contents conditionally, using an NSPredicate
, like so:
NSPredicate *pred;
switch (carType) {
case FreeCar:
pred = [NSPredicate predicateWithFormat:@"premium = NO"];
break;
case PremiumCar:
pred = [NSPredicate predicateWithFormat:@"premium = YES"];
break;
default:
pred = [NSPredicate predicateWithFormat:@"SOME PREDICATE THAT RETURNS EVERYTHING"];
break;
}
self.carArray = [aCarArrayIGotFromSomewhere filteredArrayUsingPredicate:pred];
My question is, what is the correct syntax for the value I've stubbed in as SOME PREDICATE THAT RETURNS EVERYTHING
which returns all of the instances in the array / set?
PS - I know the answer and will post it immediately, just sharing it for everyone's reference as an earlier search on SO did not yield the result.
© Stack Overflow or respective owner