Search code examples
macoscore-datanspredicate

MacOS: NSPredicate find where "one to one" relationship is not nil


I am trying to use NSPredicate to filter a Core Data fetch request. The predicate string looks like this:

"stringProperty = %@ && dateProperty > %@ && oneToOneRelationship != nil"

This is isn't returning any objects. However, if I omit the last clause it does. If I change the last clause to be "oneToOneRelationship = nil" then it does. Of course, these last two cases don't return the data I really want. :)

Is there a proper way to search for one-to-one relationships where the relationship exists and isn't nil? It seems like that predicate should be working but it isn't. This is on the current Yosemite beta using Xcode 6.1 beta.

Anyone got any ideas?


Solution

  • Actually, the "!= nil" test is working just fine. It turns out that although I thought the one-to-one relationship was being set, in fact, it wasn't. So, the predicate was working properly. It was, of course, my code that was in error.