【问题标题】:PromiseKit Cannot assign value of type '[Result<TYPE>]' to type '[TYPE]PromiseKit 无法将类型 '[Result<TYPE>]' 的值分配给类型 '[TYPE]
【发布时间】:2017-12-26 07:34:24
【问题描述】:

使用PromiseKit,我正在尝试将when 块的输出设置为局部变量allChatRooms

var allChatRooms : [ChatRoom]
var chatRoomIDs : [String:Bool] = ...
 firstly {

        when(resolved: chatRoomIDs.map{fetchChatRoom(id: $0.key)})

    }.then { chatRooms -> Void in

         allChatRooms = chatRooms <-- Error here

    } 

编译器错误是:

注意:(ChatRoomKChatRoom是一样的)

如何将结果设置为allChatRooms 变量?

【问题讨论】:

  • 投票支持与我的问题相关的问题。谢谢。

标签: swift promisekit


【解决方案1】:

解决方法很简单,我打错了when 块。相反,它应该是fulfilled 而不是resolved

when(fulfilled: chatRoomIDs.map{fetchChatRoom(id: $0.key)})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-08
    • 2021-08-05
    • 1970-01-01
    • 1970-01-01
    • 2014-01-04
    • 1970-01-01
    • 2020-08-04
    相关资源
    最近更新 更多