Core data assertion with "IN" clause in iOS 3.0
Long story short: iPhone app crashes when trying to retrieve a set of data using a group of IDs. I have a set of records tied to a user, look up all records where recordID matches any entry from user.recordIDs, crashes with error:
unimplemented SQL generation for predicate : (recordID IN {name (user.record.recordID) by user (userID) ...)
I'll open by saying, Yes, I already found this: http://cubic-m.blogspot.com/2010/03/supporting-leopard-while-developing-in.html (iOS 3.0 SQL does not support "IN" clauses using NSSets, must use NSArrays).
Predicate is in the form:
(recordID IN %@.reco开发者_如何学CrdID)
where "%@" is user.records (either a set or an array, based on article above).
That's well and good, and seemed to fix most of my application's crashes -- however, it only fixes the crashes for 3.x > 3.0. That is to say, it still doesn't fix the issue on 3.0 firmware. If anyone has any suggestions as to the nuance of early-stage Core Data, please help!
Not sure what the actual problem was here, but the fix was thus:
If we are running iOS 3, create an NSArray with all of the key objects I was looking for (here, recordIDs), and pass that to [NSPredicate predicateWithFormat:@"recordID IN %@", recordIDs]
instead of using [@"recordID in %@.recordID", records]
Again, not sure what the actual problem was, but this workaround fixed it.
精彩评论