我有三个实体:
Notification
PlanDate
User
关系:
Notification
有一对一的关系PlanDate
Notification
也有to-many关系User
代码:
NSLog (@"Selected Object From Detail ViewDidLoad %@", managedObject);
NSManagedObject *planDateObject = ((PlanDate *)[managedObject valueForKey:@"plandate"]);
NSLog(@"planDateObject %@", planDateObject);
NSString *recipientUserName = [planDateObject valueForKey:@"recipientUserName"];
NSLog(@"recipientUserName: %@", recipientUserName);
这是日志:
2013-08-21 12:26:50.349 Time[5018:c07] Selected Object From Detail ViewDidLoad <Notification: 0xa58ee70> (entity: Notification; id: 0xb2a5480 <x-coredata://C0FB76AD-19EB-42BA-981A-F99DD6DCF6C7-5018-0000101A36CFA3D1/Notification/p0B2ABAC1-77F3-4F46-B14D-34652F148B37> ; data: {
appType = 1;
invitationType = PlanDate;
lastmoddate = "2013-08-21 17:42:42 +0000";
"notification_id" = "0B2ABAC1-77F3-4F46-B14D-34652F148B37";
plandate = "0xa1c9350 <x-coredata://C0FB76AD-19EB-42BA-981A-F99DD6DCF6C7-5018-0000101A36CFA3D1/Notification/p1C004B2B-F1DA-4EE0-9FAC-0A89E0DBCDB7>";
users = "<relationship fault: 0xb2aa210 'users'>";
})
2013-08-21 12:26:50.350 Time[5018:c07] planDateObject <Notification: 0xb292800> (entity: Notification; id: 0xa1c9350 <x-coredata://C0FB76AD-19EB-42BA-981A-F99DD6DCF6C7-5018-0000101A36CFA3D1/Notification/p1C004B2B-F1DA-4EE0-9FAC-0A89E0DBCDB7> ; data: <fault>)
2013-08-21 12:26:53.406 Time[5018:c07] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<Notification 0xb292800> valueForUndefinedKey:]: the entity Notification is not key value coding-compliant for the key "recipientUserName".'
确实有一个带有值的属性“recipientUserName”。我已经尝试过产生相同日志的其他属性。
为什么会出错?为什么当我尝试访问其属性时数据显示为错误?
编辑