-1

I am recieving a SIGABRT error:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key changeToNewView.'

These are my view controllers:

import UIKit

class PhotoShareViewController: UIViewController {

    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var contentTextView: UITextView!

    @IBOutlet weak var thatTextField: UITextField!
    @IBOutlet weak var thisTextField: UITextField!
    var presenter: PhotoShareModuleInterface!
    var image: UIImage!


    @IBAction func thisUploadPhoto(_ sender: Any) {

        if thisTextField.text != "" //&& thatTextField.text != ""{
            performSegue(withIdentifier: "segue", sender: self)
        }
    }


    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

        var photoShareLabelViewController = segue.destination as! PhotoShareLabelViewController

        photoShareLabelViewController.thisString = thisTextField.text!

       // photoShareLabelViewController.thatString = thatTextField.text!

    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)

        imageView.image = image
    }

    override var prefersStatusBarHidden: Bool {
        return true
    }

    @IBAction func didTapCancel(_ sender: AnyObject) {
        presenter.cancel()
        presenter.pop()
    }

    @IBAction func didTapDone(_ sender: AnyObject) {
        guard let message = thatTextField.text, !message.isEmpty else {
            return
        }
        guard let messageOne = thisTextField.text, !messageOne.isEmpty else {
            return
        }

        presenter.finish(with: image, content:message)
        presenter.dismiss()
    }
}

extension PhotoShareViewController: PhotoShareViewInterface {

    var controller: UIViewController? {
        return self
    }
}

PhotoShareLabelViewController:

import UIKit

class PhotoShareLabelViewController: UIViewController {

    @IBOutlet weak var thisLabel: UILabel!

    @IBOutlet weak var thatLabel: UILabel!

    @IBOutlet weak var thisButton: UIButton!

    @IBOutlet weak var thatButton: UIButton!


    var thisString = String()

  //  var thatString = String()

     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        thisLabel.text = thisString

        thisButton.setTitle(thisString, for: UIControlState.normal)

     //   thatLabel.text = thatString

    //    thatButton.setTitle(thatString, for: UIControlState.normal)

    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    /*
     // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
     // Get the new view controller using segue.destinationViewController.
     // Pass the selected object to the new view controller.
     }
     */

}

I am wondering why this is happening. I checked all of the IBOutlets and IBActions on my story board and they seem to be working fine. The code where I think it's running into the error with is my segue. The code was working fine until I tried to pass data between the two view controllers.

I did the same thing on a completely empty xcode project and the code for passing data seemed to work fine, but when I try to put it in to my actual workspace it seems to have a problem.

Any help with this error would be awesome!

nayem
  • 7,285
  • 1
  • 33
  • 51
R. Musti
  • 1
  • 1
  • 4
    In your Storyboard, it seems that your `PhotoShareViewController` has a connection to `changeToNewView` which is invalid now (doesn't exist anymore). – Larme Aug 08 '17 at 14:21
  • Have you tried searching `changeToNewView` with _Find In Project.._ (Shift+Cmd+F) ? It searches inside the storyboard and may find the forgotten connection. – OOPer Aug 08 '17 at 14:45
  • now I have the error { asetValue:forUndefinedKey:]: this class is not key value coding-compliant for the key contentTextField.' } But I am one more view controller further than original error – R. Musti Aug 08 '17 at 15:06

1 Answers1

1

You have a view in your storyboard connected to an outlet in your controller. But you deleted the outlet.

Go to your storyboard, control+click the view and delete the connection by clicking on the x.

Gustavo Conde
  • 927
  • 12
  • 20
  • I've control+clicked on the 'View' button on my Document Outline for both views but the only things that pop up when I do that are those three options and none of them are filled in. Also when I select the view and go to connection inspector it doesn't look like theres any connection. – R. Musti Aug 08 '17 at 14:30
  • Do you still have the view called `changeToNewView` in your storyboard? That's the view you have to ctrl+click and delete the connection. – Gustavo Conde Aug 08 '17 at 14:33
  • That's why I was so so confused, I never had any view called 'changeToNewView' I had a segue titled that and I changed the name of the segue but I still got the 'changeToNewView' error. Your help is very appreciated! – R. Musti Aug 08 '17 at 14:35
  • Check the segue then. To see if you have something connected there. – Gustavo Conde Aug 08 '17 at 14:41