<commit_before>import UIKit

class CodeInputView: UIView, UIKeyInput {
    var delegate: CodeInputViewDelegate?
    var nextTag = 1
    var secureCode = ""
    var secure:Bool = false
    // MARK: - UIResponder

    override func canBecomeFirstResponder() -> Bool {
        return true
    }

    // MARK: - UIView

    override init(frame: CGRect) {
        super.init(frame: frame)

        // Add four digitLabels
        var frame = CGRect(x: 5, y: 0, width: 55, height: 55)
        for index in 1...4 {
            let digitLabel = UILabel(frame: frame)
            digitLabel.font = UIFont.systemFontOfSize(42)
            digitLabel.backgroundColor = UIColor.yiWhiteColor()
            digitLabel.tag = index
            digitLabel.text = " "
            digitLabel.textAlignment = .Center
            self.addSubview(digitLabel)
            frame.origin.x += 55 + 10
        }
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // MARK: - UIKeyInput

    func hasText() -> Bool {
        return nextTag > 1 ? true : false
    }

   
    
    func insertText(text: String) {
        
        if nextTag < 5 {
            (self.viewWithTag(nextTag) as! UILabel).text = text
            
            if (nextTag == 1){
             secureCode = (self.viewWithTag(nextTag) as! UILabel).text!
            } else {
             secureCode += (self.viewWithTag(nextTag) as! UILabel).text!
            }
            if secure == true {
                (self.viewWithTag(nextTag) as! UILabel).text! = "\u{2022}"
            }
            
            nextTag += 1
            
            if nextTag == 5 {
                delegate?.codeInputView(self, didFinishWithCode: secureCode)
                
            }
        }
    }

    func deleteBackward() {
        if nextTag > 1 {
            nextTag -= 1
            (self.viewWithTag(nextTag) as! UILabel).text = " "
            
            secureCode = String(secureCode.characters.dropLast())
        }
    }

    func clear() {
        while nextTag > 1 {
            deleteBackward()
        }
    }

    // MARK: - UITextInputTraits

    var keyboardType: UIKeyboardType { get { return .NumberPad } set { } }
}

protocol CodeInputViewDelegate {
    func codeInputView(codeInputView: CodeInputView, didFinishWithCode code: String)

}<commit_msg>Remove strong reference<commit_after>import UIKit

class CodeInputView: UIView, UIKeyInput {
    weak var delegate: CodeInputViewDelegate?
    var nextTag = 1
    var secureCode = ""
    var secure:Bool = false
    // MARK: - UIResponder

    override func canBecomeFirstResponder() -> Bool {
        return true
    }

    // MARK: - UIView

    override init(frame: CGRect) {
        super.init(frame: frame)

        // Add four digitLabels
        var frame = CGRect(x: 5, y: 0, width: 55, height: 55)
        for index in 1...4 {
            let digitLabel = UILabel(frame: frame)
            digitLabel.font = UIFont.systemFontOfSize(42)
            digitLabel.backgroundColor = UIColor.yiWhiteColor()
            digitLabel.tag = index
            digitLabel.text = " "
            digitLabel.textAlignment = .Center
            self.addSubview(digitLabel)
            frame.origin.x += 55 + 10
        }
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    // MARK: - UIKeyInput

    func hasText() -> Bool {
        return nextTag > 1 ? true : false
    }

   
    
    func insertText(text: String) {
        
        if nextTag < 5 {
            (self.viewWithTag(nextTag) as! UILabel).text = text
            
            if (nextTag == 1){
             secureCode = (self.viewWithTag(nextTag) as! UILabel).text!
            } else {
             secureCode += (self.viewWithTag(nextTag) as! UILabel).text!
            }
            if secure == true {
                (self.viewWithTag(nextTag) as! UILabel).text! = "\u{2022}"
            }
            
            nextTag += 1
            
            if nextTag == 5 {
                delegate?.codeInputView(self, didFinishWithCode: secureCode)
                
            }
        }
    }

    func deleteBackward() {
        if nextTag > 1 {
            nextTag -= 1
            (self.viewWithTag(nextTag) as! UILabel).text = " "
            
            secureCode = String(secureCode.characters.dropLast())
        }
    }

    func clear() {
        while nextTag > 1 {
            deleteBackward()
        }
    }

    // MARK: - UITextInputTraits

    var keyboardType: UIKeyboardType { get { return .NumberPad } set { } }
}

protocol CodeInputViewDelegate: class {
    func codeInputView(codeInputView: CodeInputView, didFinishWithCode code: String)

}
{'fraction_non_alphanumeric': 0.10025115110925073, 'fraction_numerical': 0.011301799916282964, 'mean_word_length': 1.6272677295217153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '5307350', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1372, 'n_words': 318}