2011-12-14 75 views
0

失踪我缺少的方法NSEntityDescription setCompoundIndexes在Mac OS X

  • compoundIndexes
  • setCompoundIndexes
  • 在NSEntityDescription

在Mac OS X 10.7 SDK。但是,它可以在iOS5.0 SDK中使用。

的Xcode,另一方面很清楚关于复合索引,甚至在Mac OS X上创建这样xcdatamodels:

<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> 

它可以是苹果刚刚忘了,包括在方法声明Mac API?

下面是文档:

的Mac:http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSEntityDescription_Class/NSEntityDescription.html(这里管理复合索引的部分缺失)

的iOS:http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSEntityDescription_Class/NSEntityDescription.html

回答

0

我设法通过声明它自己称之为未申报方法(需要声明,这样编译器接受它):

@interface NSEntityDescription() 
- (void)setCompoundIndexes:(NSArray*)anArray; 
@end 

后来在我的代码,在那里我创建我NSManagedObjectModel编程,我可以把它叫做:

[entity setCompoundIndexes: 
    [NSArray arrayWithObjects:[NSArray arrayWithObjects:@"open", @"close", nil], nil] 
]; 

我认为苹果刚刚忘了把方法到CoreData API。该功能在Mac OS X上也是绝对可用的,否则Xcode不会在xcdatamodel建模工具中提供UI。

我还可以确认上述语句的工作,因为我发现通过CoreData在sqlite3的数据库中创建相应的化合物索引:

CREATE INDEX ZOHLCV_ZOPEN_ZCLOSE ON ZOHLV (ZOPEN, ZCLOSE);