マイオブジェクトグラフは、このCore Dataは、多くの関係にして - サブクエリでALLでNSPredicateを作成
スナップショットのように見えます - >>ペイン - > ManagedImage
私はスナップショットを見つけようとしていること正確なManagedImagesがセットに含まれています。
このコードでは、1つ以上のManagedImagesがセットに含まれているSnapShotsの配列を返します。次に、配列を検索して正しいSnapShotを検索しますが、サブクエリでフィルタリングするほうがはるかに高速になると思います。
NSPredicateを使用すると、どのManagedImagesがセット?
は、ここに私のコードです
mySet = ... // A unique set of (usually 3) managedImages that I'm trying to find a snapShot for
NSFetchRequest *request = ...
request.entity = [NSEntityDescription entityForName:@"SnapShot" inManagedObjectContext:[self managedObjectContext]];
// Want this to work but sends an exception
//request.predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(self.panes, $pane, ALL $pane.managedImage IN %@)[email protected] != 0", mySet];
// Using this
request.predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(self.panes, $pane, $pane.managedImage IN %@)[email protected] != 0", mySet];