开发者

NSPredicate that calls test method to fetch results from Core Data

开发者 https://www.devze.com 2023-04-07 04:43 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号