NSPredicate 调用测试方法从 Core Data 获取结果
在不解释我想要做什么的情况下,我不太确定如何表达这个问题。
我有一个托管对象上下文,其中填充了(本质上)圆圈,这些圆圈具有中心点的 x,y 坐标和半径。
我想为我的核心数据检索构建一个谓词,它将找到与给定圆重叠的所有圆。
我可以编写一个布尔方法来测试它并返回 true 或 false,但我的问题是我不知道如何在谓词中调用这个测试方法。
在伪代码中,我正在尝试执行此操作:
NSPredicate *pred = [NSPredicate (if [testOverlapWithCenterAt:centerOfGivenObjectInContext andRadius:radiusOfGivenObjectInContext]);
也许 NSPredicate 甚至不是执行此操作的最佳方法。任何帮助将不胜感激。
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) circles 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
NSPredicate
的predicateWithBlock
实例方法。尝试一下。You can use the
predicateWithBlock
instance method ofNSPredicate
. Give it a try.