美文网首页
SwiftUI 将AppDelegate添加到SwiftUI应用

SwiftUI 将AppDelegate添加到SwiftUI应用

作者: fordG | 来源:发表于2020-12-15 11:11 被阅读0次
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()
        }
    }
}

相关文章

网友评论

      本文标题:SwiftUI 将AppDelegate添加到SwiftUI应用

      本文链接:https://www.haomeiwen.com/subject/fdaigktx.html