贡献者:赵大财
博客:https://my.oschina.net/zhaodacai GitHub:https://github.com/dacaizhao
邮箱: dacai_zhao@163.com QQ:327532817
=============================
//实现代理 NSCopying
func copy(with zone: NSZone? = nil) -> Any {
return type(of: self).init()
}
//let myCollectionViewCell: YouCollectionViewCell = item[1].copy() as! YouCollectionViewCell
let model1 = SBModel()
model1.str = "1"
let model2 = SBModel()
model2.str = "2"
var arr1 = [model1,model2]
var newArr = arr1.map{($0.copy() as! SBModel) }
print("==原来的值:\(arr1[0].str)")
newArr[0].str = "100"
print("==拷贝的值:\(newArr[0].str)")
print("==原来的值:\(arr1[0].str)")
required override init() {
}