title: alert view textfield notification in TableViewController
body: <p>I have TableViewController with bar button item. This is the code for bar button item.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    @IBAction func addPressed(sender: UIBarButtonItem) {
          
          var alertController = UIAlertController(title: "New Student", message: "Name", preferredStyle: UIAlertControllerStyle.Alert)
          
          var saveAction = UIAlertAction(title: "Save", style: UIAlertActionStyle.Default) { (action: UIAlertAction!) -&gt; Void in
              var textField = alertController.textFields![0] as! UITextField
              self.students.append(textField.text)
              self.tableView.reloadData()
          }
          saveAction.enabled = false
          
          var cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)
          
          alertController.addTextFieldWithConfigurationHandler { (textField: UITextField!) -&gt; Void in
              NSNotificationCenter.defaultCenter().addObserverForName(UITextFieldTextDidChangeNotification, object: textField, queue: NSOperationQueue.mainQueue(), usingBlock: { (notification: NSNotification!) -&gt; Void in
                  saveAction.enabled = textField.text != ""
              })
          }
          
          alertController.addAction(saveAction)
          alertController.addAction(cancelAction)
          
          presentViewController(alertController, animated: true, completion: nil)
          
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I am adding new String to tableview with alert controller. And using notification to enable Save button only if textfield is not empty. This exact code works with view controller with tableview inside it. But when I tested with TableViewController. Its not working. I am getting following error.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
      cd "/Users/apoorv/Desktop/tableview testing"
      export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
      /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -target x86_64-apple-ios8.3 -incremental -module-name tableview_testing -Onone -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.3.sdk -g -module-cache-path /Users/apoorv/Library/Developer/Xcode/DerivedData/ModuleCache -I /Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Products/Debug-iphonesimulator -F /Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Products/Debug-iphonesimulator -c -j1 /Users/apoorv/Desktop/tableview\ testing/tableview\ testing/AppDelegate.swift /Users/apoorv/Desktop/tableview\ testing/tableview\ testing/TableViewController.swift -output-file-map /Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/Objects-normal/x86_64/tableview\ testing-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/Objects-normal/x86_64/tableview_testing.swiftmodule -Xcc -I/Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/tableview\ testing-generated-files.hmap -Xcc -I/Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/tableview\ testing-own-target-headers.hmap -Xcc -I/Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/tableview\ testing-all-target-headers.hmap -Xcc -iquote -Xcc /Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/tableview\ testing-project-headers.hmap -Xcc -I/Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Products/Debug-iphonesimulator/include -Xcc -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -Xcc -I/Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/DerivedSources/x86_64 -Xcc -I/Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/DerivedSources -Xcc -DDEBUG=1 -emit-objc-header -emit-objc-header-path /Users/apoorv/Library/Developer/Xcode/DerivedData/tableview_testing-bcmobbjqfqwmmjhjbcdsnuctzpsi/Build/Intermediates/tableview\ testing.build/Debug-iphonesimulator/tableview\ testing.build/Objects-normal/x86_64/tableview_testing-Swift.h -Xcc -working-directory/Users/apoorv/Desktop/tableview\ testing
  
  Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1</code></pre>
  </div>
  </div>
  </p>
  
  <p>If I remove textfield.text from inside add observers then everything works fine. But I want to enable save button only if textfield is not empty. And app doest allow me to do that.</p>
  
  <p>If you need more information then I am happy to share file on GitHub.
  Let me know.</p>