I\'ve got a TextField with a numberPad and the function runs only if it contains numbers.
TextField
numberPad
The user will crash the app if they paste letters
You can create an extension for UITextField and override canPerformAction:
UITextField
canPerformAction
override public func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool { return (action != "paste:") }