[英]copyWithZone using mogenerator
我正在使用Mogenerator生成我的模型。 所以在我的人體模型中
- (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
我真的需要重新定義Human文件中的所有內容嗎?
必須使用指定的初始化程序創建NSManagedObject
實例
initWithEntity:insertIntoManagedObjectContext:
核心數據屬性訪問器方法是在運行時動態創建的,如果使用普通的init
方法創建對象,則該方法將不起作用。
這可能有效(未試用):
AppointmentGrid *appointmentGridCopy = [[[self class] allocWithZone:zone]
initWithEntity:self.entity
insertIntoManagedObjectContext:self.managedObjectContext];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.