Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 679
Jason Allen Blood Avatar asked Nov 14 '22 04:11

Jason Allen Blood


1 Answers

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]
like image 174
turingtested Avatar answered Dec 18 '22 18:12

turingtested