0

我正在尝试使用我的 iOS 应用在QuickBlox中创建一个聊天室。

[[QBChat instance] createPrivateRoomWithName:@"My Room"];


- (void)createPrivateRoomWithName:(QBChatRoom*)room{
    NSLog(@"Private room %@ was created", room.name);

    // Add users to this room
    NSNumber *anny = [NSNumber numberWithInt:300];
    NSNumber *jim = [NSNumber numberWithInt:357];
    NSArray *users = [NSArray arrayWithObjects:anny, jim, nil];

    [[QBChat instance] addUsers:users toRoom:room];
}

但是在使用此代码后,我的应用程序崩溃了,下面是崩溃日志。

2013-01-03 19:13:55.234 Chat.Points[11178:23d03] +[QBDDXMLElement elementWithName:xmlns:]: unrecognized selector sent to class 0x22f73c
2013-01-03 19:13:55.241 Chat.Points[11178:23d03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[QBDDXMLElement elementWithName:xmlns:]: unrecognized selector sent to class 0x22f73c'
*** First throw call stack:
(0x32fe012 0x29eae7e 0x33892ad 0x32edbbc 0x32ed94e 0x101e05 0x2da153f 0x2db3014 0x2da3418 0x2da32a6 0x2da4280 0x2da3fcb 0x990f7b24 0x990f96fe)
libc++abi.dylib: terminate called throwing an exception

在此处输入图像描述

4

2 回答 2

2

在创建房间之前,您必须登录 QuickBlox Chat。

解决方案是:

1)您必须将 -ObjC标志添加到其他链接器标志

2) 添加到 SplashController.h 聊天委托 QBChatDelegate

@interface SplashController : UIViewController <QBActionStatusDelegate, FBServiceResultDelegate, FBSessionDelegate, QBChatDelegate>{

3) 添加到 SplashController.m,

如果

}else if([result isKindOfClass:[QBMRegisterSubscriptionTaskResult class]]){

在顶部的下一行:

    // Login to QuickBlox Chat
    //
    [[QBChat instance] setDelegate:self];
    [DataManager shared].currentQBUser.password = [NSString stringWithFormat:@"%u", [[[DataManager shared].currentFBUser objectForKey:kId] hash]];
    [[QBChat instance] loginWithUser:[DataManager shared].currentQBUser];
    //
    //

4)最后,添加到末尾

#pragma mark-
#pragma mark QBChatDelegate

- (void)chatDidLogin{
    [[QBChat instance] createPrivateRoomWithName:@"ChatRRoom"];
}

- (void)chatRoomDidCreate:(QBChatRoom *)room{
    NSLog(@"Room did create %@", room);
    myRoom = [room retain];
}
于 2013-01-03T17:14:58.577 回答
0

只需在目标设置的其他链接器标志中添加 -ObjC 标志。希望它能解决你的问题。

于 2013-06-29T08:11:26.193 回答