Created
February 18, 2016 02:43
-
-
Save ktanaka117/f06ad0c7429aaca9996d 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