2009-09-30 4 views
2

표준 사용자 자격 증명을 보유한 AccountCredential 개체와 이러한 AccountCredential 개체를 여러 개 보유하는 다른 개체가 있습니다. CoreData에서 이것을 모델링 할 때, 보유하고있는 모든 인스턴스에 대해 AccountCredential에 Account에 대한 관계 링크가 있어야하는지 알고 싶습니다.CoreData 모델링 관계 검토

나는이 같은 CoreData에 그것을 설정합니다 :

@interface Account : NSManagedObject 
{ 
} 

@property (nonatomic, retain) AccountCredential * twitterAccountCred; 
@property (nonatomic, retain) AccountCredential * facebookAccountCred; 

@end 


@interface AccountCredential : NSManagedObject 
{ 
} 

@property (nonatomic, retain) NSString * password; 
@property (nonatomic, retain) NSString * username; // encrypted 
@property (nonatomic, retain) Account * account1; 
@property (nonatomic, retain) Account * account2; 

@end 

아니면 계정 AccountCredential에 대한 참조 및 계정 수 AccountCredential에서 어떤 관계 링크가 충분히 충분하다?

AccountCredential이 'Accounts'인터페이스에서 두 가지 유형의 계정에 사용된다는 것을 알 수있는 이유가 없으므로이를 단방향 참조로 간주합니다. 나는 CoreData가 관계를 양방향으로 좋아한다는 것을 이해하지만 이것이 모델에서 필요한지 아닌지에 대해 궁금합니다.

비 CoreData 관계는 다음과 같이 보일 것이다 : 당신이 빌드하는 경우

@interface AccountCredential : NSObject { 
    NSString *username; 
    NSString *password; //encrypted 
} 
@end 

@interface Account : NSObject { 
    AccountCredential  *twitterAccountCred; 
    AccountCredential  *facebookAccountCred; 
} 
@end 

답변

0

, 엑스 코드는 당신에게 어떤 역 관계가 없음을 경고 가능성을 제공 할 것입니다. CoreData는 역 관계가있을 때 정말 좋아합니다 (추론을 기억할 수는 없지만 실제로 생각할 때 이해가됩니다).

+0

코어 데이터는 변경이 이루어질 경우 오브젝트 그래프의 일관성을 보장하기 위해 역 관계 정보를 사용합니다. 하지만 반비례 관계를 수행 할 필요가 없는지 궁금합니다. 그렇다면이 경고를 표시하지 않을 수있는 방법이 있습니까? –

관련 문제