Dear All,
I'm trying to implement NSCopying for a NSTextFieldCell based class. But I'm getting crashes all the time, because there is an array in the new class. Here is the code:
class myTextFieldCell: NSTextFieldCell {
var thearray: [Int] = []
override func copy(with zone: NSZone?) -> Any {
let copy = super.copy(with: zone) as! myTextFieldCell
copy.thearray = []
return copy
}
}
It crashes all the time, no matter how the NSCopying is implemented, and I've tried all the options I can think of:
1. Copy the arrray as it is - copy.thearray = self.thearray
2. Initialize the array (as shown in the code above)
Any help on how to implement NSCopying in this situation will be highly appreciated.
I. Nikolov