1

我有这个奇怪的错误,不知道如何修复它。

guard let theDialogObjects = dialogObjects as! [QBChatDialog]

来自“[QBChatDialog]?”的垂头丧气 到 '[QBChatDialog]' 只解开选项;你的意思是使用'!'?

代码来自这里:https ://github.com/QuickBlox/q-municate-services-ios/blob/master/QMChatService/QMChatService/QMChatService.m

- (void)allDialogsWithPageLimit:(NSUInteger)limit
                extendedRequest:(NSDictionary *)extendedRequest
                 iterationBlock:(void(^)(QBResponse *response, NSArray *dialogObjects, NSSet *dialogsUsersIDs, BOOL *stop))iterationBlock
                     completion:(void(^)(QBResponse *response))completion {

这就是我在 Swift 中使用它的方式:

QMServicesManager.instance().chatService.allDialogsWithPageLimit(UInt.max, extendedRequest: ["type":String(QBChatDialogType.Private.rawValue)], iterationBlock: { (response, dialogObjects, userIDs, stop) in

      guard let theDialogObjects = dialogObjects as! [QBChatDialog]{
        return
      }
4

1 回答 1

3

从您没有尝试更改类型的错误消息中,只需检查该值不为零,因此您的检查应该是:

guard let theDialogObjects = dialogObjects else ...
于 2016-04-19T12:19:15.833 回答