Is it possible to sort results from Core Data based on the entity type, but:
- without resorting to adding a fake attribute called something like
entityType, and - without adversely affecting performance by using KVO/KVC tricks such as introducing
-(NSString*)typeOfEntityor similar?
I currently have:
TradeDocumentas an abstract entity, withQuoteTradeDocumentandInvoiceTradeDocumentas entities based on it.
I want to display entity type and/or allow NSTableView to be sorted based on this.
I use Cocoa Bindings on OS X.
Note: I am explicitly trying to avoid faulting each object.
Ivan,
The only limit with an abstract entity is that you can’t instantiate one. You can still fetch them. Then it is a rather simple matter of testing against which subclass each managed object is.
Sorting on type is not something a sort descriptor can do but a function can, as with
-sortUsingFunction:context:.Andrew