在QuickBlox中创build聊天室

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

[[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 

在这里输入图像说明

创build空间之前,您必须login到QuickBlox聊天。

解决scheme是:

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]; } 

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