原文:iOS面试题大全
想让自己所写的对象具有拷贝功能,则需实现 NSCopying 协议。如果自定义的对象分为可变版本与不可变版本,那么就要同时实现 NSCopying 与 NSMutableCopying 协议。
实现 NSCopying 协议。该协议只有一个方法:- (id)copyWithZone:(NSZone *)zone;。
实现 NSMutableCopying 协议。该协议只有一个方法:- (id)mutableCopyWithZone:(nullable NSZone *)zone;