2011-12-14 5 views
0

私は方法にNSEntityDescription setCompoundIndexesが見つからない

  • compoundIndexes
  • のMac OS X 10.7 SDKでNSEntityDescriptionでsetCompoundIndexes

をしないのです。しかし、これはiOS5.0 SDKで利用可能です。一方、

Xcodeは、複合インデックスについて非常によく知っているにもマック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> 

それはAppleがちょうどのメソッドの宣言を含めるのを忘れていることもできますMac API?ここで

は、ドキュメントは、次のとおりです。

マック: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] 
]; 

私はAppleがちょうどCoreDataのAPIにメソッドを置くのを忘れていると思います。この機能はMac OS Xでも利用可能です。そうしないと、XcodeはxcdatamodelモデリングツールでUIを提供しません。

CREATE INDEX ZOHLCV_ZOPEN_ZCLOSE ON ZOHLV (ZOPEN, ZCLOSE); 
:私はsqlite3のデータベースにCoreDataで作成された対応する化合物のインデックスを見つけたので

は、私はさらに、上記の文が機能していることを確認することができます。