shajem
shajem

Reputation: 2121

Writing SQL equivalent of NSPredicate - Beginner

I need to write an NSPredicate, to select all instances; For example something similar to the following SQL;

select * from person

I need to write a similar statement using NSPredicate (using nspredicate statements, and not with SQL statements).

  NSArray *allRecords= [self.records filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"HOW TO WRITE THIS"]];

Finally, according to the above example allRecords should be equal to or have the same records as self.records. (like we are selecting all the records from self.records and assigning it to allRecords)

Upvotes: 2

Views: 260

Answers (1)

mvds
mvds

Reputation: 47034

simply:

[NSPredicate predicateWithValue:YES];

If this is out of academic interest, I understand the question, but for practical purposes there are faster and cleaner ways to do what you want.

Upvotes: 4

Related Questions