QuickBlox-在一对一聊天中获取线程错误

时间:2014-10-20 13:17:44

标签: ios quickblox

您好,我可以作为用户进行身份验证,我想与Quick Blox所有者聊天,所以我使用了所有者ID与当前经过身份验证的用户聊天。

我的代码---

- (void)chatLogin
{
 QBChatDialog *chatDialog = [QBChatDialog new];    
 chatDialog.name =@"Chat With Me";    
 chatDialog.occupantIDs = @[@(1111)];
 chatDialog.type = QBChatDialogTypePrivate;
 [QBChat createDialog:chatDialog delegate:self];
}

- (void)viewDidLoad
{
[super viewDidLoad];
[self chatLogin];
// Do any additional setup after loading the view.
self.messages = [NSMutableArray array];
self.messagesTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

}

代码响应结果---

- (void)completedWithResult:(Result *)result
{
if (result.success || [result isKindOfClass:QBChatHistoryMessageResult.class] || [result isKindOfClass:[QBChatDialogResult class]])
{
    QBChatDialogResult *res = (QBChatDialogResult *)result;
    QBChatDialog *dialog = res.dialog;
    NSLog(@"Dialog: %@", dialog);

   QBChatHistoryMessageResult *res1 = (QBChatHistoryMessageResult *)result;
    NSArray *messages = res1.messages;
   [self.messages addObjectsFromArray:[messages mutableCopy]];
  [self.messagesTableView reloadData];
}
}

获取错误=

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '**setObjectForKey: object cannot be nil (key: chat_dialog_id)'

*** First throw call stack:

    **(
    0   CoreFoundation                      0x036bcdf6 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x03346a97 objc_exception_throw + 44
    2   CoreFoundation                      0x035b019c -[__NSDictionaryM 
    setObject:forKey:] + 940
    3   CoreFoundation                      0x0362c7f0 -[NSMutableDictionary 
    setObject:forKeyedSubscript:] + 48
    4   vChat                               0x00033853 -[QBCMessageGetQuery setParams:] + 243
    5   vChat                               0x0008c415 -[QBQuery setupRequest:] + 133
    6   vChat                               0x0008c11f -[QBQuery 
    performInBgAsyncWithDelegate:] + 511
    7   Foundation                          0x02f4cb57 -[NSThread main] + 76
    8   Foundation                          0x02f4cab0 __NSThread__main__ + 1326
    9   libsystem_pthread.dylib             0x03eedecf _pthread_body + 138
    10  libsystem_pthread.dylib             0x03eede45 _pthread_body + 0
    11  libsystem_pthread.dylib             0x03eebf0e thread_start + 34
)**
libc++abi.dylib: terminating with uncaught exception of type NSException**

1 个答案:

答案 0 :(得分:0)

您的问题似乎与“获取消息”查询

有关
NSMutableDictionary *extendedRequest = [NSMutableDictionary new];
extendedRequest[@"limit"] = @(100);
NSString *dialogID = @"5406cba6efa357825a00002b";
[QBChat messagesWithDialogID:dialogID extendedRequest:extendedRequest delegate:self];

我猜你的 dialogID 是零,这就是你得到例外的原因

Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: '**setObjectForKey: object cannot be nil (key: chat_dialog_id)'

dialogID不应为nil