AppDelegate.swift函数转换为swift后返回错误3(不能转换为PFBooleanResultBlock?)?

我最近把我的应用程序从以前版本的swift转换到了swift 3.0(也得到了最新版本的Xcode),在其他许多错误中,我收到了以下一个错误:

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托pipe的Parse-server)。 返回错误说:“不能将types'(Bool,NSError?) – >()'的值转换为期望的参数types'PFBooleanResultBlock?'”

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

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

  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) } } 

Swift 3你可以这样写:

  PFPush.subscribeToChannel(inBackground: "") { (succeeded, error) 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) } }