Created
February 20, 2016 12:48
-
-
Save ktanaka117/901caf50183d061dec60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewControlle { | |
@IBOutlet weak var textField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// !!! なんか長い !!! | |
NSNotificationCenter.defaultCenter().addObserver(self, selector: "textDidChange:", name: UITextFieldTextDidChangeNotification, object: textField) | |
} | |
// !!! 処理が遠い&ジャンプできない !!! | |
func textDidChange(notification: NSNotification) { | |
print((notification.object as? UITextField)?.text) | |
} | |
// !!! deinit時にremoveし忘れる !!! | |
deinit { | |
NSNotificationCenter.defaultCenter().removeObserver(self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment