         notificationCenter.removeObserver(self, name: UIKeyboardWillHideNotification, object: nil)
         notificationCenter.removeObserver(self, name: UIKeyboardDidShowNotification, object: nil)
     }
-
-    /**
-     A private method called when the keyboard is about to be hidden.
-
-     - parameter sender: An `NSNotification` containing a `Dictionary` with information regarding the keyboard appearance.
-     - author: Daniel Loewenherz
-     - copyright: ©2016 Lionheart Software LLC
-     - date: February 18, 2016
-     */
-    func keyboardWillHide(sender: NSNotification) {
-        guard let conformingSelf = self as? KeyboardAdjuster else {
-            return
-        }
-
-        if let constraint = conformingSelf.keyboardAdjusterConstraint {
-            if let block = sender.object as? (() -> Void) {
-                block()
-            }
-
-            if let userInfo = sender.userInfo as? [String: AnyObject],
-                _curve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? Int,
-                curve = UIViewAnimationCurve(rawValue: _curve),
-                duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as? Double,
-                animated = conformingSelf.keyboardAdjusterAnimated {
-                    var curveAnimationOption: UIViewAnimationOptions
-                    switch curve {
-                    case .EaseIn:
-                        curveAnimationOption = .CurveEaseIn
-
-                    case .EaseInOut:
-                        curveAnimationOption = .CurveEaseInOut
-
-                    case .EaseOut:
-                        curveAnimationOption = .CurveEaseOut
-
-                    case .Linear:
-                        curveAnimationOption = .CurveLinear
-                    }
-
-                    constraint.constant = 0
-                    if animated {
-                        let animationOptions: UIViewAnimationOptions = [UIViewAnimationOptions.BeginFromCurrentState, curveAnimationOption]
-
-                        UIView.animateWithDuration(duration, delay: 0, options: animationOptions, animations: {
-                            self.view.layoutIfNeeded()
-                            }, completion:nil)
-                    }
-                    else {
-                        view.layoutIfNeeded()
-                    }
-            }
-        }
-    }
-    /**
-     A private method called after the keyboard is shown.
-     
-     - parameter sender: An `NSNotification` containing a `Dictionary` with information regarding the keyboard appearance.
-     - author: Daniel Loewenherz
-     - copyright: ©2016 Lionheart Software LLC
-     - date: February 18, 2016
-     */
-    func keyboardDidShow(sender: NSNotification) {
-        guard let conformingSelf = self as? KeyboardAdjuster else {
-            return
-        }
-
-        if let constraint = conformingSelf.keyboardAdjusterConstraint {
-            if let block = sender.object as? (() -> Void) {
-                block()
-            }
-            
-            if let userInfo = sender.userInfo as? [String: AnyObject],
-                value = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue {
-                    let frame = value.CGRectValue()
-                    let keyboardFrameInViewCoordinates = view.convertRect(frame, fromView: nil)
-
-                    if let _curve = userInfo[UIKeyboardAnimationCurveUserInfoKey] as? Int,
-                        curve = UIViewAnimationCurve(rawValue: _curve),
-                        duration = userInfo[UIKeyboardAnimationDurationUserInfoKey] as? Double,
-                        animated = conformingSelf.keyboardAdjusterAnimated {
-                            var curveAnimationOption: UIViewAnimationOptions
-                            switch curve {
-                            case .EaseIn:
-                                curveAnimationOption = .CurveEaseIn
-                                
-                            case .EaseInOut:
-                                curveAnimationOption = .CurveEaseInOut
-                                
-                            case .EaseOut:
-                                curveAnimationOption = .CurveEaseOut
-                                
-                            case .Linear:
-                                curveAnimationOption = .CurveLinear
-                            }
-
-                            constraint.constant = CGRectGetHeight(view.bounds) - keyboardFrameInViewCoordinates.origin.y
-                            let animationOptions: UIViewAnimationOptions = [UIViewAnimationOptions.BeginFromCurrentState, curveAnimationOption]
-                            if animated {
-                                UIView.animateWithDuration(duration, delay: 0, options: animationOptions, animations: {
-                                    self.view.layoutIfNeeded()
-                                    }, completion: nil)
-                            }
-                            else {
-                                view.layoutIfNeeded()
-                            }
-                    }
-            }
-        }
-    }
 }

import UIKit

public protocol KeyboardAdjuster {
    var keyboardAdjusterConstraint: NSLayoutConstraint? { get set }
    var keyboardAdjusterAnimated: Bool? { get set }
}

extension UIViewController {
    /**
     Activates keyboard adjustment for the calling view controller.


     - date: February 18, 2016
     */
    public func activateKeyboardAdjuster(showBlock: AnyObject?, hideBlock: AnyObject?) {
        // Activate the bottom constraint.
        keyboardAdjusterConstraint?.active = true

        let notificationCenter = NSNotificationCenter.defaultCenter()
        notificationCenter.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIKeyboardWillHideNotification, object: hideBlock)
        notificationCenter.addObserver(self, selector: #selector(keyboardDidShow(_:)), name: UIKeyboardDidShowNotification, object: showBlock)

        guard let viewA = keyboardAdjusterConstraint?.firstItem as? UIView,
            let viewB = keyboardAdjusterConstraint?.secondItem as? UIView else {
                return
        }

        if viewB.subviews.contains(viewA) {
            assertionFailure("Please reverse the order of arguments in your keyboard Adjuster constraint.")
        }
    }
    
