SwiftUI 将AppDelegate添加到SwiftUI应用

2020-12-15  本文已影响0人  fordG
import SwiftUI

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        print("Your code here")
        return true
    }
}

@main
struct iDineApp: App {
    
    //将AppDelegate添加到SwiftUI应用
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    
    var body: some Scene {
        WindowGroup {
            AppView()
        }
    }
}
上一篇下一篇

猜你喜欢

热点阅读