Jason Allen Blood
Jason Allen Blood

Reputation: 51

NSPredicate - Core Data - Compare two properties to each other

I have what I thought would be an easy thing to do / find on the Google-verse but have been totally baffled. I have a single object with two date properties setup in Core Data. I want to grab a list of objects where the two dates are not the same. How can I do this using Core Data?

[NSPredicate predicateWithFormat:@"dateModified != dateCreated"];

does not work.

Upvotes: 5

Views: 526

Answers (1)

turingtested
turingtested

Reputation: 7154

The format you are using is searching for a key-value relation, but you have keys on both sides, dateModified and dateCreated. Try something like this:

[NSPredicate predicateWithFormat:@"(dateModified != %@)", someObject.dateCreated]

Upvotes: 1

Related Questions