使用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
}
编译错误是:
如何将结果设置为allChatRooms
变量?
答案 0 :(得分:2)
解决方案很简单,我错误地输入了when
块。相反,它应该是fulfilled
而不是resolved
when(fulfilled: chatRoomIDs.map{fetchChatRoom(id: $0.key)})