<commit_before>//
//  KeyboardManager.swift
//  RichEditorViewSample
//
//  Created by <NAME> on 4/5/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import RichEditorView

/**
    KeyboardManager is a class that takes care of showing and hiding the RichEditorToolbar when the keyboard is shown.
    As opposed to having this logic in multiple places, it is encapsulated in here. All that needs to change is the parent view.
*/
class KeyboardManager: NSObject {

    /**
        The parent view that the toolbar should be added to.
        Should normally be the top-level view of a UIViewController
    */
    weak var view: UIView?

    /**
        The toolbar that will be shown and hidden.
    */
    var toolbar: RichEditorToolbar

    init(view: UIView) {
        self.view = view
        toolbar = RichEditorToolbar(frame: CGRect(x: 0, y: view.bounds.height, width: view.bounds.width, height: 44))
        toolbar.options = RichEditorOptions.all()
    }

    /**
        Starts monitoring for keyboard notifications in order to show/hide the toolbar
    */
    func beginMonitoring() {
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShowOrHide:", name: UIKeyboardWillShowNotification, object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShowOrHide:", name: UIKeyboardWillHideNotification, object: nil)
    }

    /**
        Stops monitoring for keyboard notifications
    */
    func stopMonitoring() {
        NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
        NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)<commit_msg>Use #selector instead of string selectors<commit_after>//
//  KeyboardManager.swift
//  RichEditorViewSample
//
//  Created by <NAME> on 4/5/15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit
import RichEditorView

/**
    KeyboardManager is a class that takes care of showing and hiding the RichEditorToolbar when the keyboard is shown.
    As opposed to having this logic in multiple places, it is encapsulated in here. All that needs to change is the parent view.
*/
class KeyboardManager: NSObject {

    /**
        The parent view that the toolbar should be added to.
        Should normally be the top-level view of a UIViewController
    */
    weak var view: UIView?

    /**
        The toolbar that will be shown and hidden.
    */
    var toolbar: RichEditorToolbar

    init(view: UIView) {
        self.view = view
        toolbar = RichEditorToolbar(frame: CGRect(x: 0, y: view.bounds.height, width: view.bounds.width, height: 44))
        toolbar.options = RichEditorOptions.all()
    }

    /**
        Starts monitoring for keyboard notifications in order to show/hide the toolbar
    */
    func beginMonitoring() {
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardManager.keyboardWillShowOrHide(_:)), name: UIKeyboardWillShowNotification, object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardManager.keyboardWillShowOrHide(_:)), name: UIKeyboardWillHideNotification, object: nil)
    }

    /**
        Stops monitoring for keyboard notifications
    */
    func stopMonitoring() {
        NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillShowNotification, object: nil)
        NSNotificationCenter.defaultCenter().removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
{'fraction_non_alphanumeric': 0.08711283185840708, 'fraction_numerical': 0.006084070796460177, 'mean_word_length': 3.3895631067961167, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3226854', 'n_tokens_mistral': 976, 'n_tokens_neox': 936, 'n_words': 318}