私には基本クラスが@interface BaseMailbox : NSManagedObject
あり、その 2 人の子供がいます。次の方法でのみ、クラスのオブジェクトを作成できるようです。
BaseMailbox *mailbox;
mailbox = [NSEntityDescription
insertNewObjectForEntityForName:@"BaseMailbox"
inManagedObjectContext:context];
Core Data オブジェクトはポリモーフィズムをサポートしていないようですか?
編集:
たとえば、メールボックスオブジェクトを作成する前に、次を使用しました。
account = [[GoogleMailbox alloc]
initWithFullName
そして私が電話したときaccount.connect
-それはgmail paramsとの接続でした。
しかし、今account
ではどの子オブジェクトも参照していません。私が呼び出すと、account.connect
基本クラスのメソッドが呼び出されます。
EDIT2
BEFORE CORE DATA:
if([_emailAddress.text endsWith:SUFFIX_GOOGLE]){
account = [[GoogleMailbox alloc]
initWithFullName:_fullName.text emailAddress:_emailAddress.text password:_password.text];
}else if([_emailAddress.text endsWith:SUFFIX_YAHOO]){
account = [[YahooMailbox alloc]
initWithFullName:_fullName.text emailAddress:_emailAddress.text password:_password.text];
}else{
..........
BOOL success = [account connect]; // GoogleMailbox or YahooMailbox or ...,depending the account refers to.
コアデータ:
BaseMailbox* account = [NSEntityDescription
insertNewObjectForEntityForName:@"MailBox"
inManagedObjectContext:context];
}else{
..........
BOOL success = [account connect]; // BaseMailbox