A NSManagedObject has a property as Transformable which I use to store a NSMutableOrderedSet.
This set contains custom objects (not subclasses of NSManagedObject) which implement NSCoding and override the isEqual: and hash methods.
I have a NSPredicate which checks if this set contains a passed object.
The predicate is basically this one:
[NSPredicate predicateWithFormat:@"%@ IN %K", theObjectToCheck, @"propertyNameForTheSet"];
It works with the database in memory but with SQL it fires a BAD ACCESS error.
I have all diagnostics enabled.
The sql debug is something like:
CoreData: sql: SELECT COUNT( DISTINCT t0.Z_PK) FROM ZIMPLEMENTED_ABSTRACT_ENTITY_NAME t0 WHERE ( NSCoreDataStringSearch( t0.ZPROPERTYNAMEFORTHESET1, ?, 0, 0) AND t0.Z_ENT = ?)
CoreData: details: SQLite bind[0] = theObjectToCheckAsString(not-hash)
CoreData: details: SQLite bind[1] = 6
The stack trace is:
0 ??? 0x00000001eee4d8dc 0x0 + 8302942428,
1 Spatch 0x00000001020d5ee0 main + 0,
2 CoreData 0x000000010386ee26 _NSCoreDataStringSearch + 246,
3 libsqlite3.dylib 0x0000000107337384 sqlite3VdbeExec + 16100,
4 libsqlite3.dylib 0x000000010728e4ff sqlite3_step + 527,
5 CoreData 0x0000000103820070 _execute + 112,
6 CoreData 0x000000010381fd0b -[NSSQLiteConnection execute] + 1835,
7 CoreData 0x0000000103879b18 -[NSSQLChannel selectCountWithFetchRequest:] + 168,
8 CoreData 0x00000001038796b5 -[NSSQLCore countForFetchRequest:inContext:] + 405,
9 CoreData 0x0000000103825f01 -[NSSQLCore executeRequest:withContext:error:] + 513,
10 CoreData 0x00000001038fb4f3 __65-[NSPersistentStoreCoordinator executeRequest:withContext:error:]_block_invoke + 3331,
11 CoreData 0x00000001039037ee gutsOfBlockToNSPersistentStoreCoordinatorPerform + 190,
12 libdispatch.dylib 0x00000001056b17f4 _dispatch_client_callout + 8,
13 libdispatch.dylib 0x0000000105698774 _dispatch_barrier_sync_f_invoke + 365,
14 CoreData 0x00000001038f63d5 _perform + 197,
15 CoreData 0x0000000103825ac8 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 504,
16 CoreData 0x0000000103878c80 -[NSManagedObjectContext(_NSInternalAdditions) _countWithNoChangesForRequest:error:] + 288,
17 CoreData 0x000000010387868b -[NSManagedObjectContext countForFetchRequest:error:] + 331,
It seems there are similarities with: http://markmail.org/message/7cuuamyc4gcid5bb#query:+page:1+mid:h2t4o4moib3emltb+state:results
Sample project can be checked here: https://dl.dropboxusercontent.com/u/2935618/CustomObjectsInCoreData.zip
Any ideas how I could get to the bottom of this? Thanks a lot!
It seems it's not possible to search for objects in NSPredicate with SQL if these are not entities and are not connected through an explicit relationship in the core data model.