问题
I have an CoreData entity class X, which stores an NSArray of NSString IDs, inside a transformable attribute (lets say someIDs)...
Given an NSString ID, how can i find (using Predicate) all entities X, which contains the ID, in their someIDs attribute?
Note: i know about relationships (so no need to propose using a relationship) etc. but what to do in this case?
回答1:
You can't. A transformable attribute is store as a data blob in the SQLite store file (using NSCoding
methods). The Core Data fetch request (which is translated to a SQLite query)
has no access to the contents of the transformable attribute.
If you don't want to use a to-many relationship then you can only fetch all objects and filter the fetched NSArray
.
来源:https://stackoverflow.com/questions/21697987/core-data-transformable-nsarray-of-ids