NSPredicate фильтруют данные через отношения, а не свойство

Вот мой вопрос. У меня есть эта модель одна [Событие], имеет несколько [День] и существуют отношения, названные днями в [Событии] и в [День] существует обратное событие отношений.

Теперь я хочу, передают Объект-событие и получают все дни с помощью NSFetchedResultsController и подают все дни в таблице. Вот мой код:

// Create the fetch request for the entity.
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Day" inManagedObjectContext:managedObjectContext];

//set predicate  ->  ??
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"event = %@", self.currentEvent];
[fetchRequest setPredicate:predicate];

//set entity
[fetchRequest setEntity:entity];

// Set the batch size to a suitable number.
[fetchRequest setFetchBatchSize:20];

// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];

[fetchRequest setSortDescriptors:sortDescriptors];

// Edit the section name key path and cache name if appropriate.
// nil for section name key path means "no sections".
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest 
                                                                                            managedObjectContext:managedObjectContext 
                                                                                              sectionNameKeyPath:nil
                                                                                                       cacheName:nil];

Так или иначе экземпляр NSFetchedResultsController будет всегда возвращать то же самое для другого события. Как я должен зафиксировать NSPredicate?

7
задан zs2020 6 August 2010 в 04:40
поделиться