Using Core Data, I have a fetch request to fetch the minimum of a certain attribute using an expression. If I set a predicate on the request that results in no results being matched, I get EXC_BAD_ACCESS. This makes some sense, seeing as you can’t add nil to an NSArray for the results, but what’s the best way around this?
I can just use a sort order and a fetch limit of 1, but it seems a bit of the oversight in the NSExpressionDescription API that there’s no way to return a default result or return an empty array if no objects were matched before evaluating the expression.
Or am I misdiagnosing the EXC_BAD_ACCESS entirely, and NSExpressionDescriptions, used in setPropertiesToFetch on a fetch request should already behave sensibly for this situation?
The workaround in the second paragraph is what I’ve had to use, so this appears to just be an API oversight.