I came up with a solution to this using subquery, but I don\'t understand why what I was trying to do first didn\'t work.
Here\'s my data model. I\'m fetching on Adv
I believe you cannot use nil in the query. You should maybe use NULL or the format string construct like "ANY conditions.terrain == %@", nil.
What puzzles me is that your subquery is working...
The above is not correct, as NULLand NILcan be used interchangeably.
Instead, the NSExpression Class Reference gives exactly your pattern (with @count) as the preferred example.
Did you check that the terrain relationship is optional?