gpt4 book ai didi

swift - 从类 'UIApplication' 和 'FBSDKApplicationDelegate' 多重继承

转载 作者:行者123 更新时间:2023-11-28 15:13:33 30 4
gpt4 key购买 nike

我正在使用来自 facebook 网站的 iOS SDK https://developers.facebook.com/docs/ios ,但是当我将 FBSDKApplicationDelegate 添加到 App delegate 时,我收到一个错误

Multiple inheritance from classes 'UIApplication' and 'FBSDKApplicationDelegate'.

我不能使用 Swift SDK,因为我的项目是在 XCode 8.2.1 上,Swift SDK for Facebook 需要 8.3

最佳答案

看起来你正在通过这种方式或类似的方式使用 FBSDKApplicationDelegate

class AppDelegate: UIResponder, UIApplicationDelegate, FBSDKApplicationDelegate

请看FBSDKApplicationDelegate仔细。

Discussion: The methods in this class are designed to mirror those in UIApplicationDelegate, and you should call them in the respective methods in your AppDelegate implementation.

它不是那样使用的。不要从 FBSDKApplicationDelegate 继承 AppDelegate。让我们在 AppDelegate 的方法中使用 FBSDKApplicationDelegate 的方法

您可以按照此问题中的答案学习如何使用 FBSDKApplicationDelegate Integration new facebook SDK by swift

func applicationDidBecomeActive(application: UIApplication!) {
FBSDKAppEvents.activateApp()
}

func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String, annotation: AnyObject?) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

为了更详细和易于理解,我使用 Facebook iOS SDK 创建了一个演示项目 IntegrateFBSDK .你可以试试。

关于swift - 从类 'UIApplication' 和 'FBSDKApplicationDelegate' 多重继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47239310/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com