Skip to content

Instantly share code, notes, and snippets.

@ktanaka117
Created February 18, 2016 02:42
Show Gist options
  • Save ktanaka117/675e94cfdbbb6868aa1e to your computer and use it in GitHub Desktop.
Save ktanaka117/675e94cfdbbb6868aa1e to your computer and use it in GitHub Desktop.
import UIKit
// !!! プロトコルの採用とDelegateのセット忘れでつまづく(※ここではStoryboard上でVCと紐付けています) !!!
// textField.delegate = selfのことです。
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet weak var textField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}
// !!! 複数のDelegateメソッドがある際に処理の順序が追いづらい !!!
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
print(string)
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment