我有这个奇怪的错误,不知道如何修复它。
guard let theDialogObjects = dialogObjects as! [QBChatDialog]
Downcast from '[QBChatDialog]?' to '[QBChatDialog]' only unwraps optionals; did you mean to use '!'?
- (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/