2017-05-05 41 views
-1

我已经下载了ParseStarterProject版本1.14.3和下载后,要求我先转换为迅速3.之后给我一个错误:解析入门套件的斯威夫特3

Cannot convert value of type '(Bool, NSError?) ->()' to expected argument type '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) 
     } 
    } as! PFBooleanResultBlock as! PFBooleanResultBlock as! PFBooleanResultBlock as! PFBooleanResultBlock as! PFBooleanResultBlock as! PFBooleanResultBlock as! PFBooleanResultBlock 
} 

我试着用另一个线程(AppDelegate.swift function returning errors after converting to swift 3 (cannot convert to PFBooleanResultBlock?)?

解决,但给我这个错误:

"Expected) in the expression list" 

http://imgur.com/nkdnEZp

+0

是作为7列表! PFBooleanResultBlock'是一个错字?你为什么选择这种类型? – nathan

+0

这是Xcode自动转换为swift 3 ...但即使没有这个错字它不起作用。 –

+0

看起来你的确切问题已经在这里解决:http://stackoverflow.com/a/39684760/6658553 – nathan

回答

1

我试图复制相同的错误,我只是更换swift3生成代码:

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


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

} 

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { 
    if error._code == 3010 { 
     print("Push notifications are not supported in the iOS Simulator.\n") 
    } else { 
     print("application:didFailToRegisterForRemoteNotificationsWithError: %@\n", error) 
    } 
} 

的工作原理

我的项目是here

+0

谢谢!大多数人只是投下了票,因为他们甚至没有检查到迅速改变,并有新的问题,你解决它。再次感谢你。 –

+0

@RenatoPimpão这是真的!没问题,我很高兴解决你的问题 –

+0

Julien,这个简单的“error._code”刚刚救了我一天。我已经搜索了如何管理任何地方的可选无济于事。我不得不忽略一个代码= 1的值,但是拆除那个错误对象看起来很糟糕。为什么Apple做出一些简单的事情,比如获取error.code太难了,超出了我的想象。 –