我在Xcode8发行之前开始使用该应用程序,然后进行切换,当我尝试使用Facebook登录名登录该应用程序时,出现以下错误
找不到application:openURL:sourceApplication:annotation:的实现。请将处理程序添加到您的应用程序委托中。类:GhostGab.AppDelegate
我检查了所有设置,它们看起来还不错。任何帮助将不胜感激
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
func application(application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
let facebookDidHandle = FBSDKApplicationDelegate.sharedInstance().application(
application,
open: url,
sourceApplication: sourceApplication,
annotation: annotation)
// Add any custom logic here.
return facebookDidHandle
}
最佳答案
您的函数定义:
func application(application: UIApplication, openURL url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool {
}
应替换为:
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
}
第一个参数带有下划线,而最后一个参数类型则带有
Any
而不是AnyObject
。这就是为什么出现错误的原因:
application:openURL:sourceApplication:annotation的实现