저는 게임과 플레이어 사이에 일대일 관계가 있습니다. 플레이어라고 불리는 Games to Players에는 관계가 있습니다.코어 데이터 - NSPredicate와 to-many 관계
게임 < - >> 플레이어
게임 엔티티 선수라는 관계가있다. 플레이어의 이름이 '주문'입니다.
관계를 쿼리하는 데 술어를 사용할 수 없습니다. 여기에 내가 사용하고있는 코드는 다음과 같습니다
-(NSArray *)returnPlayerLastAtBat: (int)rosterNo
{
NSError *error;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Games" inManagedObjectContext:managedObjectContext];
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(finished = '%d') and (players.order = '%d')",0,rosterNo];
[fetchRequest setEntity:entity];
[fetchRequest setPredicate:predicate];
NSArray* result = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
[fetchRequest release];
return result;
}
아니 내 프로젝트 - 전체에 입각 한 작업을 할 수 있어요하지만,이 하나 붙어있다 뭐가 잘못 내가 뭐하는 거지 확인합니다.
당신은 술어 형식으로 따옴표가 필요 없다고 생각합니다. 그것이 술어를 깨뜨릴 지 확실하지 않지만 시도할만한 가치가있다. – mvds
참고로 테이블 이름은 관습에 따라 단수입니다 (예 : 게임 및 플레이어) – MGA
인용문은 미학을위한 것이며 코드에 영향을 미치지 않습니다. –