How to live check a NSTextField - Swift OS X
问题 I am currently making an OS X application written in Swift. What I want to do is when the user enters text in a NSTextField , I want to run a function that checks the value and adds it to a Label. How would I do this in swift? 回答1: Conforms ViewController to protocol NSTextDelegate . Assign ViewController as Delegate for TextField . Implement controlTextDidChange method. import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate, NSTextFieldDelegate { @IBOutlet weak