I\'ve setup an NSTextField with text color as white, and the background color as (black despite not rendering the background color, so its transparent). All in
I've called insertionPointColor in viewDidLoad and app crashes.
I fixed this by calling insertionPointColor on viewDidAppear.
For Swift developers:
Set insertionPointColor method into extension:
extension NSTextField {
public func customizeCursorColor(_ cursorColor: NSColor) {
let fieldEditor = self.window?.fieldEditor(true, for: self) as! NSTextView
fieldEditor.insertionPointColor = cursorColor
}
}
and call
override func viewDidAppear() {
super.viewDidAppear()
textField.customizeCursorColor(NSColor.red)
}