Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 采用NSCOPY协议的正确方式是什么?_Objective C - Fatal编程技术网

Objective c 采用NSCOPY协议的正确方式是什么?

Objective c 采用NSCOPY协议的正确方式是什么?,objective-c,Objective C,我对Objective-C中的NSCopying协议有疑问。请参考以下代码: 超级班: @interface superClassA : NSObject <NSCopying> @接口超类:NSObject 子类: @interface subClassB : superClassA <NSCopying> @接口子类B:超类 我想:我可以重写super的-(id)copyWithZone:(NSZone*)zone方法 因此,我是否需要在子类(子类B)中声明协

我对Objective-C中的NSCopying协议有疑问。请参考以下代码:

超级班:

@interface superClassA : NSObject <NSCopying>
@接口超类:NSObject
子类:

@interface subClassB : superClassA <NSCopying>
@接口子类B:超类
我想:我可以重写super的
-(id)copyWithZone:(NSZone*)zone
方法


因此,我是否需要在子类(
子类B
)中声明
协议?

您不需要重新声明子类B符合NSCopying协议。据说子类也符合其父类所符合的所有协议。

是的,简而言之:类继承协议。