3

I have an attribute with an int_32 property called seconds. In a category, I restate the property as readonly and override the getter to create it from other properties. The issue is when I use

[NSPredicate predicateWithFormat:@"SELF.seconds > %i"];

The predicate does not work because the getter is not called by the predicate. It is called in my other code just fine, just not in the predicate. Anyone know why this would happen or how to get around this problem? (besides recreating NSFetchedResultsController).

4

1 回答 1

4

谓词被转换为 SQL 并在存储上运行。它不运行您的任何代码。因此,您只能使用数据存储中的存储值。没有瞬态属性,没有方法。

如果要在 fetch 中使用该属性,则应保存该值。这可以通过willSave在保存任何其他值更改之前实现并让它设置值来完成。

于 2013-09-01T12:48:33.340 回答