IMO this is a much better answer than the accepted.
func shouldChangeText(inRanges affectedRanges: [NSValue], replacementStrings: [String]?) -> Bool
is the place to change it.
Topic:
UI Frameworks
SubTopic:
AppKit
Tags: