views:

69

answers:

1

Hi,

I have an entity called Task in my Core Data model. The Task entity has a transformable attribute called date. The class of the date attribute is a class called TDate (which conforms to NSCoding, therefore being a transformable attribute). TDate has a property of type NSInteger called month.

In my NSFetchRequest I want to get all Task objects of a specific month. I'm using the following predicate:

[NSPredicate predicateWithFormat:@"date.month == 7"]

That should get me all Task objects in the month of July. However, with this predicate, no fetched objects are returned. I can confirm that there are Task objects whos month is 7 (July) by taking out the predicate. Is there something wrong with my predicate syntax?

Thanks

+2  A: 

If you're using an SQLite backend, then you cannot search against transformable properties. On the SQLite backend, the fetch request's predicate is transformed to SQL and executed on the SQLite engine. Because SQLite has no knowledge of Cocoa, predicates that execute against the SQLite backend can't use transformable properties.

If you're using an XML, binary or in-memory store, you can use predicates that query against transformable properties since the entire object graph is in-memory and is queried using native Cocoa.

Barry Wark
I ended up creating separate attributes for each property of the `date` object. Thanks.
macatomy