Core Data: Fetch via specific property (join relationship)

后端 未结 2 857
情话喂你
情话喂你 2021-02-10 16:41

I have an core data model as follows

\"alt

The attributes property of Page

2条回答
  •  执念已碎
    2021-02-10 17:06

    Assuming you start by knowing the "key" to the DictionaryEntry of "Title".

    Why don't create an NSFetchRequest on the DictionaryEntry object using your known "key" when you create an NSPredicate.

        NSFetchRequest *request = [[NSFetchRequest alloc] init];
    [request setEntity:[NSEntityDescription entityForName:@"DictionaryEntry" inManagedObjectContext:_context]];
    [request setPredicate:[NSPredicate predicateWithFormat:@"key == %@", keyValue]];
    

    Once you have your valid DictionaryEntry object, you can then use your CoreData crufted up "page" relationship to get your valid Page.

提交回复
热议问题