I am missing the methods
- compoundIndexes
- setCompoundIndexes
in NSEntityDescription in the Mac OS X 10.7 SDK. It is however, available in the iOS5.0 SDK.
Xcode on the other hand knows very well about compound indexes, even under Mac OS X. It creates xcdatamodels like this:
<entity name="OHLCV" parentEntity="Sample" syncable="YES">
<attribute name="close" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="high" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="low" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="open" attributeType="Double" defaultValueString="0.0" syncable="YES"/>
<attribute name="volume" attributeType="Integer 64" defaultValueString="0" syncable="YES"/>
<compoundIndexes>
<compoundIndex>
<index value="open"/>
<index value="close"/>
</compoundIndex>
</compoundIndexes>
</entity>
Can it be that Apple just forgot to include declarations of the methods in the Mac API?
Here are the docs:
Mac: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSEntityDescription_Class/NSEntityDescription.html (here the section for managing compound indexes is missing)
I have managed to call the undeclared method by declaring it myself (needs to be declared so that the compiler accepts it):
later in my code, where I create my NSManagedObjectModel programmatically I can call it:
I think Apple has just forgotten to put the methods into the CoreData API. The feature is definitely available also on Mac OS X, otherwise Xcode would not offer a UI in the xcdatamodel modelling tool.
I can further confirm that the above statements are working, because I found the corresponding compound index created by CoreData in the sqlite3 database: