Skip to content

Instantly share code, notes, and snippets.

@VojtaStavik
Created March 31, 2015 16:45
Show Gist options
  • Save VojtaStavik/0d0095cf7254f4be2fea to your computer and use it in GitHub Desktop.
Save VojtaStavik/0d0095cf7254f4be2fea to your computer and use it in GitHub Desktop.
class SSNTextField: UITextField {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
registerForNotifications()
}
override init(frame: CGRect) {
super.init(frame: frame)
registerForNotifications()
}
deinit {
NSNotificationCenter.defaultCenter().removeObserver(self)
}
private func registerForNotifications() {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "textDidChange", name: "UITextFieldTextDidChangeNotification", object: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment