Spelling in NSTextField with Swift

How to check spelling NSTextFieldwith swift? I already use controlTextDidChangeto check the text. This decision seems to indicate that the first responder was like NSTextView, but I'm not sure if this is possible with a quick use of coercion. I know that it would be easier if I changed to NSTextView, but if possible, I would like to avoid it.

+4
source share
1 answer

This should help you.

// Focus TextField
phraseTextField.becomeFirstResponder()
// Enable Continous Spelling
let textView: NSTextView = (self.window!.firstResponder as! NSTextView)
textView.continuousSpellCheckingEnabled = true

Adapted from: How to enable spell checking in NSTextField on Mac OS X?


NSTextField NSTextView s. " " ( NSTextView ), . NSTextFields , .

: https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextView_Class/#//apple_ref/doc/uid/20000373-SW55

+1

All Articles