我正在嘗試使用也是瞬態的未定義屬性。這個屬性的類型是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是零,所以我試圖設置它,但後來我得到這個錯誤:
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有一些問題。結果發現,解決了這個問題後,二傳手確實奏效。 –