I am trying to get deep copy of an class object which contains nested object in swift, Can anyone help ?
Code which I tried
Here is my class:
class ZLFilters: NSObject, NSCopying {
var filterChoices : [ZLFilterChoice]?
required init(_ map: Map){
}
init(filterChoices : [ZLFilterChoice]) {
self.filterChoices = filterChoices
}
func copyWithZone(zone: NSZone) -> AnyObject {
let copy = ZLFilters(filterChoices: filterChoices!)
return copy
}
}
But the problem is filterChoices is itself an object, so again internally it does not do deep copy.