views:

36

answers:

1

I'm using CoreData backed by SQLite and I'm trying to find the fastest way to exclude rows where the field AirDate ends with -00-00

I've noticed that

[NSPredicate predicateWithFormat:@"NOT AirDate CONTAINS %@", @"-00-00"]

is much faster than

[NSPredicate predicateWithFormat:@"NOT AirDate LIKE %@", @"*-00-00"]

Are there any other optimizations that I can make? Thanks!

A: 

You could try using a regular expression:

[NSPredicate predicateWithFormat:@"NOT AirDate MATCHES %@", @"-00-00$"]

But you probably should use NSDate instead of storing the date as a string. It should be faster to search using date comparisons instead of matching strings.

Sven