我有个奇怪的错误,不知道该怎么解决。
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
}
最佳答案
从错误消息中可以看出,您没有试图更改类型,只需检查值是否不是nil,因此您的检查应该是:
guard let theDialogObjects = dialogObjects else ...
关于swift - 仅从可包装的可选产品中向下转换;您是要使用'!'吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36718046/