2016-09-22 38 views
1

最近,我將我的應用程序從以前的版本雨燕SWIFT的3.0(也拿到了最新的Xcode版本)和許多其他錯誤中,我收到了以下之一:轉換爲swift 3後,AppDelegate.swift函數返回錯誤(無法轉換爲PFBooleanResultBlock?)?

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-server)。錯誤返回說:「不能將類型'(Bool,NSError?) - >()'的值轉換爲期望的參數類型'PFBooleanResultBlock?'」

不知道如何解決這個問題。有人有任何想法嗎?

回答

4

我相信你可以改變你這樣的代碼:

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

隨着斯威夫特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) 
     } 
    } 
相關問題