1

I am having a strange issue. I am trying to pass an object from ViewControllerA to CreateInvitationViewController.

In ViewControllerA I have following code:

func btnPassedRequestTouched(sender:UIButton!)
{
    print("button passed request touched")
    // pass request
    self.performSegueWithIdentifier("createInvitationSegue", sender: self)

}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
    if segue.identifier == "createInvitationSegue" {
        let createInvitationView = segue.destinationViewController as! CreateInvitationViewController
        let invitation = invitations[self.carousel.currentItemIndex]
        createInvitationView.invitation = invitation
    }
}

I put a breakpoint on this line: createInvitationView.invitation = invitation, and I can see that this object exists.

In ViewControllerB I have the following code:

class CreateInvitationViewController: UIViewController {

    var invitation = Invitation()

    override func viewDidLoad() {
        super.viewDidLoad()

        // if invitation is set, then use it to populate fields
        if let _ = self.invitation.id {
            invitationText.hidden = false
            invitationText.text = self.invitation.note
        }
    }

I am using Show action on the segue that I made and it looks like this: Show action This is the error that I am getting:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<MyProject.CreateInvitationViewController 0x156365810> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key postRequest.'

Do you have some suggestion why this happens?

1 Answer 1

3

It's telling you it cannot find postRequest. That means that you either have some code that is trying to set postRequest or, more likely, you have some control in your storyboard that is trying to connect to an outlet called postRequest, but no such outlet exists (e.g. maybe you had some outlet with that name in the past, removed the outlet from the code, but neglected to update the storyboard accordingly).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.