私は、一時的な未定義の属性を使用しようとしています。この属性はABRecordRef型(Objective-Cではオブジェクトでもありません)で、ABRecordIDを使用してオブジェクトを取得できます。これは、モデルで保持するint32です。コアデータ:定義されていない一時的な属性を使用
私はかなり簡単にゲッターを作った:
- (ABRecordRef) abRecordPerson
{
ABAddressBookRef book = ABAddressBookCreate();
ABRecordRef record = ABAddressBookGetPersonWithRecordID(book, [self.abGlobalID intValue]);
return record;
}
私は新しいオブジェクトを保存しようとするまでこれは、正常に動作します:
Person *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
newManagedObject.abGlobalID = [NSNumber numberWithInt: recordID];
//newManagedObject.abRecordPerson = person;
私がコメントアウト最後の行を持っているかどうかのクラッシュを取得か否か。それはコメントアウトだ場合、それは私に、このエラーを与える:
Unresolved error Error Domain=NSCocoaErrorDomain Code=1570 "The operation couldn’t be completed. (Cocoa error 1570.)" UserInfo=0xe0138c0 {NSValidationErrorObject= (entity: Person; id: 0xc611e10 ; data: { abGlobalID = 6; abRecordPerson = nil; })
abRecordPersonがnilであると考えているようだ、私はそれを設定しようとしましたが、その後、私はこのエラーを取得する:
CoreData: error: Property 'setAbRecordPerson:' is a scalar type on class 'Person' that does not match its Entity's property's scalar type. Dynamically generated accessors do not support implicit type coercion. Cannot generate a setter method for it. 2011-06-21 20:07:18.100 TestCoreDataLab[79616:207] -[Person setAbRecordPerson:]: unrecognized selector sent to instance 0x6d10f40
どれでも役立つだろう大変感謝します。
私は持っていましたが、iOS5の問題がありました。それが問題であると分かった後、セッターは働きます。 –