SWIFT: Nstextfield allow only specified characters
问题 I need somebody to show me how to allow specific characters in a nstexfield in swift. For example when a user tries to enter a character which is not in the list the nstexfield will not show that character in the field.. Very simple. There are many IOS examples out there but could not find an OSX example. 回答1: First add a NSTextFieldDelegate to your class... and then add this : override func controlTextDidChange(obj: NSNotification) { let characterSet: NSCharacterSet = NSCharacterSet