NSmanagedObject copyWithZone问题 [英] NSmanagedObject copyWithZone issues

查看:107
本文介绍了NSmanagedObject copyWithZone问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义类Thing:NSManagedObject的属性为adminName。

I have a custom class Thing:NSManagedObject with an attribute of adminName.

我试图在这个Thing类中创建一个copyWithZone函数,但是当我运行应用程序说明setAdminName不存在。

I am trying to create a copyWithZone function in this Thing class, but when I run the app it says setAdminName doesn't exist.

在我的实现文件中我使用

In my implementation file I am using

@dynamic adminName;


-(id) copyWithZone: (NSZone *) zone
{
Thing *regCopy = [[Thing allocWithZone: zone] init];
regCopy.attendeeNum = [self adminName];

return regCopy;
}



我不认为我可以把@dynamic改成@synthesize,因为我我使用Core Data。

I don't believe I can just change @dynamic to @synthesize since I am using Core Data.

推荐答案

NSManagedObject不符合NSCopying协议。如果要创建具有相同数据的新记录,只需插入一个新对象,并将值从第一个对象分配给第二个对象。

NSManagedObject does not conform to the NSCopying protocol. If you want to create a new record with the same data, just insert a new object and assign the values from the first object to the second object.

这篇关于NSmanagedObject copyWithZone问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆