PromiseKit无法分配类型&#39; [Result <type>]&#39;的值输入&#39; [TYPE]

时间:2017-12-26 07:34:25

标签: swift promisekit

使用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

    } 

编译错误是:

enter image description here 注意:(ChatRoomKChatRoom相同)

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

1 个答案:

答案 0 :(得分:2)

解决方案很简单,我错误地输入了when块。相反,它应该是fulfilled而不是resolved

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