我已按照步驟將 Firebase 用于我正在創建的 macOS 應用程式。我貼:
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
FirebaseApp.configure()
return true
}
}
進入我的代碼,但它給出了 UIApplicationDelegate 的錯誤。
我認為這是因為我需要 NS 用于 macOS 應用程式,但是當我執行 NSApplicationDelegate 時,它??給出了錯誤“'LaunchOptionsKey' 不是類 'AppKit.NSApplication' 的成員型別”。我該如何解決?
uj5u.com熱心網友回復:
作為 macOS 的應用程式意味著您不會有任何UI*
課程。
在 macOS 中,應用程式委托是NSApplicationDelegate
. applicationDidFinishLaunching
委托方法的簽名是func applicationDidFinishLaunching(_ notification: Notification)
.
所以你的代碼變成了這樣:
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
FirebaseApp.configure()
}
}
這實際上不是使 Firebase 與 macOS 兼容的問題。這更多是使用 AppKit 代碼而不是 UIKit 代碼的問題。Firebase 代碼在這里無關緊要。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/533050.html
標籤:Google Cloud Collective 迅速火力基地
上一篇:以更Swift友好的方式重寫
下一篇:無法在Swift中將資料寫入檔案