我試圖訪問一個像這樣的變形芯數據對象的屬性:核心數據可轉換屬性
MainObject *localObject = [self.myArray objectAtIndex:indexPath.row];
TransformableObject *actualObject = localObject.transformableObject;
這工作得很好。我NSLog
actualObject
並得到正確的鍵/值對:
actualObject:{
property = "Foo";
property2 = "Apple";
}
然而,當我我嘗試:
NSLog (@"property:%@",actualObject.property)
我得到-[__NSCFDictionary property]: unrecognized selector sent to instance
我在做什麼錯?在我的核心數據類,我有:
@interface MainObject : NSManagedObject
@property (nonatomic, retain) TransformableObjectClass *transformableObject;
編輯: 下面是如何設置的對象在覈心數據
MainObject *event = (MainObject *)[NSEntityDescription insertNewObjectForEntityForName:@"MainObject" inManagedObjectContext:[AppDelegateMy managedObjectContext]];
[event setValuesForKeysWithDictionary:[myArrray objectAtIndex:i]];
最初如何設置'localObject.transformableObject'的值?在您的模型中如何配置屬性? 'actualObject'顯然是一個'NSDictionary',但是你沒有給我們足夠的信息來推論爲什麼。 –
TransformableObjectClass是另一個Core Data NSManagedObject類。 – Eric
可能是這樣,但錯誤顯示實際分配給該屬性的實例是'NSDictionary'的實例。那麼,它是如何到達那裏的? –