title: How to use the keyboard "Go" to submit UITextFields like a UIButton in Swift 2
body: <p>Ok so I have a function that allows my user to use the keyboard to go to the next field (Which I got the code from SO) It works perfect. My problem is, once my user gets to the final text field, in which, I've selected "GO" as the return button, and I want to use the go as the ideal submit button. As the flow through the form goes, its presentably right, but the functionality at the end isn't there. I found an answer here, but it looks like its calling the same functions as the "next field" code. So they don't work well together. So here's what the Next Field code looks like:</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
      // Keyboard Next Field &amp; Delegate
      enterEmailTextField.delegate = self
      enterPasswordTextField.delegate = self
      self.enterEmailTextField.nextField = self.enterPasswordTextField
      self.enterPasswordTextField.nextField = self.enterNameTextField
      // ...
  }
  </code></pre>
  
  <p>And the next block is displayed below override (which i'm sure you know) <code>func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() }</code>   </p>
  
  <pre><code>// Next Field
  func textFieldShouldReturn(textField: UITextField) -&gt; Bool {
      if let nextField = textField.nextField {
          nextField.becomeFirstResponder()
      }
  
      return true
  }
  </code></pre>
  
  <p>Ok that works just fine down to the last text field, But since the last field is "Go" I'm trying to mimic what I would do with say an @IBAction for a button, but instead the go button. Here's where I got the idea/code for the Go to work: </p>
  
  <p><a href="https://stackoverflow.com/questions/13065868/action-of-the-go-button-of-the-ios-keyboard">Action of the &quot;Go&quot; button of the ios keyboard</a></p>
  
  <p>Any Ideas on how to implement these? Or maybe just to work with the next function, and implement a "keyboard go" action similar to an @IBaction? Maybe just an all around better way to implement both of these so they coincide with each other? Any help is much appreciated!</p>
  
  <p>EDIT!</p>
  
  <p>I forgot the actual NextField.swift File which I'm sure is important (sorry)</p>
  
  <pre><code>import Foundation
  import UIKit
  
  private var kAssociationKeyNextField: UInt8 = 0
  
  
  extension UITextField {
      @IBOutlet var nextField: UITextField? {
          get {
              return objc_getAssociatedObject(self,     &amp;kAssociationKeyNextField) as? UITextField
          }
           set(newField) {
              objc_setAssociatedObject(self, &amp;kAssociationKeyNextField,     newField, UInt(OBJC_ASSOCIATION_RETAIN))
          }
      }
  }
  </code></pre>
  
  <p>this would help a lot I'm assuming</p>