Reputation: 645
I have actually a core data entity called Show and for every show I have a relation ship called Schedule that contains an attribute called schedules which is an array.
What I want to do is to create a Predicate that checks for a given show's schedule if it has more than 1 item.
To do That I tried Two solutions :
NSPredicate * predicate = [NSPredicate predicateWithFormat:@"schedule.schedules > 1];
NSPredicate * predicate = [NSPredicate predicateWithFormat:@"schedule.schedules.@count > 1];
But None of them would work.
NB : schedules attribute is an stored in my Core Data as Transformable and declared as an id variable.
Upvotes: 2
Views: 590
Reputation: 2052
Did you try this?
NSPredicate * predicate = [NSPredicate predicateWithFormat:@"@count.schedule.schedules > 1];
Upvotes: 0
Reputation: 119031
A transformable attribute is stored as binary data, and it isn't unpacked until the container entity is loaded into memory. So, you can't use any kind of predicate based on a transformable attribute in a fetch. It will only work to filter the results of the fetch.
Cheap solution is to store a simple integer attribute with the count and use that.
Better solution is likely to add / change your entities so you use a relationship instead of a transformable.
Upvotes: 2