Jean-Luc Godard
Jean-Luc Godard

Reputation: 1883

Predicate Query for CoreData

I want to write a search function using NSPredicate to search for the start of an element [Not contains, which I currently have but start].

Right now my predicate is:

NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF contains[cd] %@", searchText];

How can I search the string from the start ?

Upvotes: 0

Views: 62

Answers (1)

Wain
Wain

Reputation: 119041

Use BEGINSWITH instead of CONTAINS. Note that you can still use [cd] when using BEGINSWITH.

See the full documentation here.

Upvotes: 1

Related Questions