问题
I have a collection of Calendar
objects and want to query them by their service_id
property. I'm using Core Data on iPhone 3.2 SDK with sqlite.
calendars
is a NSArray result of a NSFetchRequest
. I'm plucking the service_id
property out of each object in the NSArray.
NSPredicate *tripsWithServiceId = [NSPredicate predicateWithFormat:@"service_id IN %@", [calendars valueForKey:@"service_id"]];
However this generates an exception:
'NSInvalidArgumentException', reason: 'unimplemented SQL generation for predicate : (service_id IN {"DEC10-Multi-Weekday-01", "MAR11-Multi-Weekday-01", "MAR11-Multi-Weekday-02"})'
The following SQL query in the sqlite console will return the results I expect:
select ztrip.zservice_id from ztrip WHERE ztrip.zservice_id IN ("DEC10-Multi-Sunday-01", "DEC10-Multi-Sunday-01");
I'm just trying to replicate that with NSPredicate if that helps.
Tried re-reading the docs, and tried out a number of proposed fixes. Checked in IRC and someone else thought the syntax looked fine. Any tips? Totally stuck here. Thanks.
来源:https://stackoverflow.com/questions/5062881/nspredicate-iphone-3-2-sdk-core-data-in-clause-nsinvalidargumentexception-exce