<commit_before>//
//  ViewController.swift
//  TextField
//
//  Created by anseungjin on 2015. 8. 19..
//  Copyright (c) 2015년 bamssong. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var inputTextField: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //show keyboard
        inputTextField.becomeFirstResponder()
        
        //
        let gestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
        self.view.addGestureRecognizer(gestureRecognizer)
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        //keyboard show & hide 감시
        NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name: UIKeyboardDidShowNotification, object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name: UIKeyboardWillHideNotification, object: nil)
    }
    
    override func viewDidDisappear(animated: Bool) {
        //remove notification observer.
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    //
    func handleTap(gesture : UITapGestureRecognizer) {
        if let firstRespond = self.findFirstResponder(self.view) {
            firstRespond.resignFirstResponder()
        }
    }

    //
    func keyboardWillShow(noti : NSNotification) {
        //VIEW RESIZE?
    }
    
    func keyboardWillHide(noti : NSNotification) {
        //VIEW RESIZE?
    }
    
    
    
    //TextField
    @IBAction func textFieldDidEndExit(sender: UITextField) {
        
    }
    
    @IBAction func textFieldEditingChanged(sender: UITextField) {
        self.label.text = sender.text
    }
    
    @IBAction func textFieldEditingDidBegin(sender: UITextField) {
        self.label.textColor = UIColor.redColor()
    }
    
    @IBAction func textFieldEditingDidEnd(sender: UITextField) {
        self.label.textColor = UIColor.blackColor()
    }
    
    
    //Button
    @IBAction func hideKeyboard(sender: UIButton) {
        if let responder = findFirstResponder(self.view) {
            responder.resignFirstResponder()
        }
    }
    
    
    func findFirstResponder(view :UIView) -> UIResponder? {
        for v in view.subviews {
            if (v as? UIControl != nil) {<commit_msg>keyboard 체크 함수 코드 개<commit_after>//
//  ViewController.swift
//  TextField
//
//  Created by anseungjin on 2015. 8. 19..
//  Copyright (c) 2015년 bamssong. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    @IBOutlet weak var label: UILabel!
    @IBOutlet weak var inputTextField: UITextField!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //show keyboard
        inputTextField.becomeFirstResponder()
        
        //
        let gestureRecognizer = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
        self.view.addGestureRecognizer(gestureRecognizer)
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        //keyboard show & hide 감시
        NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name: UIKeyboardDidShowNotification, object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name: UIKeyboardWillHideNotification, object: nil)
    }
    
    override func viewDidDisappear(animated: Bool) {
        //remove notification observer.
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
    
    //
    func handleTap(gesture : UITapGestureRecognizer) {
        if let firstRespond = self.findFirstResponder(self.view) {
            firstRespond.resignFirstResponder()
        }
    }

    //
    func keyboardWillShow(noti : NSNotification) {
        //VIEW RESIZE?
    }
    
    func keyboardWillHide(noti : NSNotification) {
        //VIEW RESIZE?
    }
    
    
    
    //TextField
    @IBAction func textFieldDidEndExit(sender: UITextField) {
        
    }
    
    @IBAction func textFieldEditingChanged(sender: UITextField) {
        self.label.text = sender.text
    }
    
    @IBAction func textFieldEditingDidBegin(sender: UITextField) {
        self.label.textColor = UIColor.redColor()
    }
    
    @IBAction func textFieldEditingDidEnd(sender: UITextField) {
        self.label.textColor = UIColor.blackColor()
    }
    
    
    //Button
    @IBAction func hideKeyboard(sender: UIButton) {
        if let responder = findFirstResponder(self.view) {
            responder.resignFirstResponder()
        }
    }
    
    
    func findFirstResponder(view :UIView) -> UIResponder? {
        for v in view.subviews {
            if (v is UIControl) {
{'fraction_non_alphanumeric': 0.09314690823158724, 'fraction_numerical': 0.004332414336352895, 'mean_word_length': 2.5393728222996517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6641184', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1498, 'n_words': 293}