     }
 
 }
-
-@objc extension FormController {
-
-    func donePressed() {
-        resignResponders()
-    }
-
-    func nextTextField() {
-        let nextIdx = responders.index(of: currentResponder!)! + 1
-        responders[nextIdx].becomeFirstResponder()
-    }
-
-    func previousTextField() {
-        let previousIdx = responders.index(of: currentResponder!)! - 1
-        responders[previousIdx].becomeFirstResponder()
-    }
-
-}


public class FormController: NSObject {

    fileprivate var responders: [UIResponder]!
    fileprivate var oldTextFieldDelegates: [UITextField: UITextFieldDelegate?] = [:]
    fileprivate var oldTextViewDelegates: [UITextView: UITextViewDelegate?] = [:]
    fileprivate var currentResponder: UIResponder?

    public init(responders: [UIResponder]) {
        super.init()
        self.responders = responders

        for responder in responders {
            if let textField = responder as? UITextField {
                oldTextFieldDelegates[textField] = textField.delegate
                textField.delegate = self
                textField.inputAccessoryView = accessoryViewForResponder(responder: textField)
                if responders.index(of: responder)! < responders.count - 1 {
                    textField.returnKeyType = .next
                } else {
                    textField.returnKeyType = .done
                }
            } else if let textView = responder as? UITextView {
                oldTextViewDelegates[textView] = textView.delegate
                textView.delegate = self
                textView.inputAccessoryView = accessoryViewForResponder(responder: textView)
                if responders.index(of: responder)! < responders.count - 1 {
                    textView.returnKeyType = .next
                } else {
                    textView.returnKeyType = .done
                }
            } else {
                fatalError("Unsupported responder type.")
            }
        }
    }

}

    }

    public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        let idx = inputViews.index(of: textField)!
        if idx == inputViews.count - 1 {
            resignResponders()
        } else {
            nextInputView()
        }

        if let delegate = oldTextFieldDelegates[textField], let unwrappedDelegate = delegate, let delegateResponse = unwrappedDelegate.textFieldShouldReturn?(textField) {
