objective-cjsqmessagesviewcontrollernsunknownkeyexception

This class is not key value coding-compliant for the key connectionView: JSQMessagesViewController


I'm attempting to call/load an instance of JSQMessagesViewController I'm reusing from a previous/different project and I'm getting the following error message:

 "This class is not key value coding-compliant for the key connectionView."

I believe the issue is being caused by an issue in the following (a part of my WidgetsVC.m file):

  case 2:{

        JSQChat *fcvc = [[JSQChat alloc] initWithNibName:@"JSQChat" bundle:[NSBundle mainBundle]];
        [appDelegate.chatNavController setViewControllers:[NSArray arrayWithObject:fcvc]
                                                   animated:NO];
        appDelegate.cpTabBarController .selectedIndex = 2;


        break;

I've tried many of the suggestions commonly associated with this error and none of them seem to resolve it (uninstalling the app, bad connection in XIB, checking to ensure Targets > Summary > iPhone/iPod Deployment Info > Main Interface is blank, etc. etc.):

What does this mean? "'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X"


Solution

  • You are trying to create a JSQChat object from the JSQChat.xib file. The xib specifies that the object you create will have a connectionView outlet. JSQChat doesn't have such an outlet defined.

    Probably the reason that you don't see anything broken in the visual editor is that you've defined the xib's file owner to be HomeVC, with does contain:

        IBOutlet UIView *connectionView;