NSPredicate iPhone 3.2 SDK Core Data “IN clause” NSInvalidArgumentException exception

巧了我就是萌 提交于 2019-12-04 00:38:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!