NSPredicate调用测试方法从Core Data获取结果

时间:2011-09-26 01:37:53

标签: iphone ios core-data nspredicate nsmanagedobjectcontext

我不太确定如何解释这个问题而不解释我想要做什么。

我有一个托管对象上下文,其中包含(基本上)圆圈,这些圆圈的中心点和半径都有x,y坐标。

我想为我的核心数据检索构建一个谓词,它将找到与给定圆重叠的所有圆圈。

我可以编写一个布尔方法来测试它并返回true或false,但我的问题是我不知道如何在我的谓词中调用这个测试方法。

在伪代码中,我试图这样做:

NSPredicate *pred = [NSPredicate (if [testOverlapWithCenterAt:centerOfGivenObjectInContext andRadius:radiusOfGivenObjectInContext]);

也许NSPredicate甚至不是最好的方法。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

您可以使用predicateWithBlock的{​​{1}}实例方法。试一试。