Created
April 9, 2019 14:43
-
-
Save corbinstreehouse/d5601d0f543999c66c1a8111ae5a5ec1 to your computer and use it in GitHub Desktop.
Implementing [NSCell copyWithZone:] in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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