简体   繁体   English

更新PromiseKit后发生错误:无法将类型&#39;PMKFinalizer&#39;的值转换为预期的参数类型&#39;Promise <Void> “

[英]Error after update PromiseKit: Cannot convert value of type 'PMKFinalizer' to expected argument type 'Promise<Void>'

This code worked with PromiseKit v.4.5.2 . 该代码可与PromiseKit v.4.5.2一起使用。

func getReminderIds(idArray: [Int]) {

    var reminderPromises: [Promise<Void>] = []

    for id in idArray {
        if let prom = self.delegate?.getReminders(id).then({ (reminderArray) -> Promise<Void> in
            Utils.logMessage("Reminders for asset \(id): \(reminderArray)")
            self.reminders[String(id)] = reminderArray
        }).catch({ (err) in
            self.reminders[String(id)] = nil
            Utils.logMessage("Error getting reminders for asset \(id): \(err)")
        }){

            reminderPromises.append(prom)
        }

    }

    _ = when(fulfilled: reminderPromises).done { results -> Void in
        self.collectionView?.refreshCollection(collection: 0)
    }

}

But after updating to PromiseKit v.6.8.4 I get the error "Cannot convert value of type 'PMKFinalizer' to expected argument type 'Promise'" in this line: 但是在更新到PromiseKit v.6.8.4之后,我在此行中收到错误“无法将类型'PMKFinalizer'的值转换为预期的参数类型'Promise'”

reminderPromises.append(prom)
struct Reminder {
    let id: Int
    let value: [String: Any]
}

func getReminderIds(idArray: [Int]) {

        var reminderPromises: [Promise<Reminder>] = []

        for id in idArray {
            reminderPromises.append(getReminders(id))
        }

        _ = when(fulfilled: reminderPromises).done { results -> Void in
            for item in results {
                print(item.id)
                print(item.value)
            }
        }

    }

    func getReminders(_ id: Int) -> Promise<Reminder> {
        // TODO network request or database request
        return Promise { $0.fulfill(Reminder(id: id, value: [:])) }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法将类型&#39;(_)-&gt;()&#39;的值转换为预期的参数类型&#39;((Bool,Error?)-&gt; Void)? - Cannot convert value of type '(_) -> ()' to expected argument type '((Bool, Error?) -> Void)?' 无法将类型&#39;()&#39;的值转换为预期的参数&#39;()-&gt; void&#39; - cannot convert value of type '()' to expected argument '() -> void' 无法将“Void”类型的值转换为预期的参数类型“(String) -> Void” - Cannot convert value of type 'Void' to expected argument type '(String) -> Void' 无法将类型&#39;() - &gt; Void&#39;的值转换为预期的参数类型&#39;(( - - &gt; Void)?&#39; - Cannot convert value of type '() -> Void' to expected argument type '(() -> Void)?' 无法将类型“(Void)-&gt;()”的值转换为预期的参数类型“()-&gt; Void” - Cannot convert value of type '(Void) -> ()' to expected argument type '() -> Void' 错误:无法将类型&#39;(_,_)-&gt; Void&#39;的值转换为预期的参数类型&#39;(((UIAlertAction)-&gt; Void)? - Error: Cannot convert value of type '(_, _) -> Void' to expected argument type '((UIAlertAction) -> Void)?' 无法转换类型&#39;(_)-&gt;()的值? 到预期的参数类型&#39;@convention(block)()-&gt; Void&#39; - Cannot convert value of type '(_) -> ()?' to expected argument type '@convention(block) () -> Void' 无法使用完成处理程序将类型“()”的值转换为预期的参数类型“()-&gt; Void” - Cannot convert value of type '()' to expected argument type '() -> Void' with a completionHandler Swift 无法将类型“()”的值转换为预期的参数类型“() -> Void” - Swift Cannot convert value of type '()' to expected argument type '() -> Void' 无法将类型 &#39;(_) throws -&gt; ()&#39; 的值转换为预期的参数类型 &#39;((UIAlertAction) -&gt; Void)?&#39; - Cannot convert value of type '(_) throws -> ()' to expected argument type '((UIAlertAction) -> Void)?'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM