博客> 自定义类的拷贝
自定义类的拷贝
2019-05-21 14:23 评论:0 阅读:935 pinglan_z
ios

自定义类的拷贝,需要实现NSCopying协议 -(id)copyWithZone:(NSZone *)zone 在该方法中,大致要实现的内容如下(ItemData中的属性为自定义的): -(id)copyWithZone:(NSZone )zone { ItemData copyData = [[ItemData alloc]init]; copyData.nItemID = nItemID; copyData.nPriorityLevel = nPriorityLevel; copyData.fProgress = fProgress; copyData.strMissionTitle = strMissionTitle; copyData.strMissionDetail = strMissionDetail; copyData.strMissiontips = strMissiontips; copyData.dateDeadLine = dateDeadLine; copyData.dateCreateTime = dateCreateTime; copyData.strRelativePersons = strRelativePersons; copyData.nRemindTime = nRemindTime; copyData.bRemindOrNot = bRemindOrNot; return copyData; }

收藏
1
sina weixin mail 回到顶部