-1

I have integrated TokBox for chatting functionality in my iOS app.

I have used this link

this is my code

- (void)sessionDidConnect:(OTSession*)session {

    // When we've connected to the session, we can create the chat component.

    // crash on following line

    _textChat = [[OTKTextChatComponent alloc] init];

    _textChat.delegate = self;

    [_textChat setMaxLength:1050];
    [_textChat setSenderId:session.connection.connectionId alias:session.connection.data];

    CGRect r = self.view.bounds;
    r.origin.y += 20;
    r.size.height -= 20;
    [_textChat.view setFrame:r];
    [self.view addSubview:_textChat.view];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

    // fade in
    _textChat.view.alpha = 0;

    [UIView animateWithDuration:0.5 animations:^() {
        //_connectingLabel.alpha = 0;
        _textChat.view.alpha = 1;
    }];

}

This demo is working perfectly. But when I am trying to integrate it in my project. It gives following error :

Unknown class OTKTextChatView in Interface Builder file.
 *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x7f8c43835fa0> setValue:forUndefinedKey:]: 

this class is not key value coding-compliant for the key countLabel.'
    *** First throw call stack:

please help me

Johnykutty
  • 12,091
  • 13
  • 59
  • 100
Maulik shah
  • 1,664
  • 1
  • 19
  • 45

1 Answers1

1

This is because OTKTextChatView class is not loaded before the xib loads (since it was in an external library). Normally we are setting -all_load, but in the documentation it says

Do not use the -all_load linker flag. Instead, use the -force_load linker flag to load specific libraries that require it.

If this doesn't help try to add the following code in your application did finish launching method

[OTKTextChatView class];

This will forcefully load OTKTextChatView class.

This will help you.

As per Maulik's suggestion:- Add this three library OTKTextChatLibrary,OTKTextChatBundle & OTKTextChatBundle.bundle..if you don't add this then this type error occur

Johnykutty
  • 12,091
  • 13
  • 59
  • 100