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:
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?