NSPredicate that calls test method to fetch results from Core Data
I am not quite sure how to word this question without explaining what I am trying to do.
I have a managed object context filled with (essentially) cir开发者_Python百科cles that have an x,y coord for the center point and a radius.
I would like to construct a predicate for my core data retrieval that will find all circles that overlap with a given circle.
I can write a boolean method that tests this and returns true or false, but my problem is that I don't know how to call this testing method in my predicate.
in pseudo-code, I am trying to do this:
NSPredicate *pred = [NSPredicate (if [testOverlapWithCenterAt:centerOfGivenObjectInContext andRadius:radiusOfGivenObjectInContext]);
Perhaps NSPredicate isn't even the best way to do this. Any help would be much appreciated.
You can use the predicateWithBlock
instance method of NSPredicate
. Give it a try.
精彩评论