我在用莫格内斯特制作我的模型。所以在我的人类模型里
- (id)copyWithZone:(NSZone *)zone
{
AppointmentGrid *appointmentGridCopy = [[[self class] allocWithZone:zone] init];
[appointmentGridCopy setEmployeeId:self.employeeId];
[appointmentGridCopy setEmployeeObject:self.employeeObject];
[appointmentGridCopy setServiceId:self.serviceId];
[appointmentGridCopy setServiceObject:self.serviceObject];
[appointmentGridCopy setStartTimestamp:self.startTimestamp];
[appointmentGridCopy setEndTimestamp:self.endTimestamp];
[appointmentGridCopy setAppointmentGridSlots:self.appointmentGridSlots];
return appointmentGridCopy;
}由于Machine类拥有所有属性,所以我没有将它们读到Human中。但是我得到了一个错误
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppointmentGrid setEmployeeId:]: unrecognized selector sent to instance我真的需要重新定义我的人类文件中的所有内容吗?
发布于 2014-02-05 17:38:49
必须使用指定的初始化器创建NSManagedObject实例。
initWithEntity:insertIntoManagedObjectContext:核心数据属性访问器方法是在运行时动态创建的,如果对象是用普通的init方法创建的,则无法工作。
这可能有效(未经测试):
AppointmentGrid *appointmentGridCopy = [[[self class] allocWithZone:zone]
initWithEntity:self.entity
insertIntoManagedObjectContext:self.managedObjectContext];https://stackoverflow.com/questions/21584201
复制相似问题