Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Implementing [NSCell copyWithZone:] in Swift
// Swift 3.0
class TableViewTextFieldCell: NSTextFieldCell {
private var previousTextColor: NSColor?
override func copy(with zone: NSZone? = nil) -> Any {
let result: TableViewTextFieldCell = super .copy(with: zone) as! TableViewTextFieldCell
if let previousTextColor = result.previousTextColor {
// Add the needed retain now
let _ = Unmanaged<NSColor>.passRetained(previousTextColor)
}
return result
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment