AppDelegate.swift 函数在转换为 swift 3 后返回错误(无法转换为 PFBooleanResultBlock?)? [英] AppDelegate.swift function returning errors after converting to swift 3 (cannot convert to PFBooleanResultBlock?)?

查看:28
本文介绍了AppDelegate.swift 函数在转换为 swift 3 后返回错误(无法转换为 PFBooleanResultBlock?)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的应用程序从 swift 的先前版本转换为 swift 3.0(并且还获得了最新版本的 Xcode),并且在许多其他错误中,我收到了以下错误:

I recently converted my app from the previous version of swift to swift 3.0 (and also got the most recent version of Xcode) and, among many other errors, I received the following one:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let installation = PFInstallation.current()
        installation.setDeviceTokenFrom(deviceToken)
        installation.saveInBackground()

        PFPush.subscribeToChannel(inBackground: "") { (succeeded: Bool, error: NSError?) in
            if succeeded {
                print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.\n");
            } else {
                print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", error)
            }
        }
    }

这来自我作为模板下载的 SDK(PF 指的是 Parse 框架...我使用的是由 Heroku 托管的 Parse 服务器).返回的错误是:无法将 '(Bool,NSError?)-> ()' 类型的值转换为预期的参数类型 'PFBooleanResultBlock?'"

This came from an SDK that I downloaded as a template (the PF is referring to Parse framework... I am using a Parse-server hosted by Heroku). The error is returned saying: "Cannot convert value of type '(Bool,NSError?)-> ()' to expected argument type 'PFBooleanResultBlock?'"

不知道如何解决这个问题.有人有什么想法吗?

Not sure how to fix this. Does anybody have any ideas?

推荐答案

我相信你可以像这样改变你的代码:

I believe you can change your code like this:

    PFPush.subscribeToChannel(inBackground: "", block: {(succeeded, error) -> Void in
        if succeeded {
            print("ParseStarterProject successfully subscribed to push notifications on the broadcast channel.\n");
        } else {
            print("ParseStarterProject failed to subscribe to push notifications on the broadcast channel with error = %@.\n", error)
        }
    }

这篇关于AppDelegate.swift 函数在转换为 swift 3 后返回错误(无法转换为 PFBooleanResultBlock?)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆