为什么我的应用程序委托文件SwiftUI没有输出
为什么控制台中没有该代码的任何输出:为什么我的应用程序委托文件SwiftUI没有输出,swift,swiftui,Swift,Swiftui,为什么控制台中没有该代码的任何输出: import SwiftUI class AppDelegate: NSObject, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]) -> Bool { ContentView().changeL
import SwiftUI
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]) -> Bool {
ContentView().changeListe()
print("called")
return true
}
}
@main
struct Order_Corner_V8App: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var window: UIWindow?
var body: some Scene {
return WindowGroup {
ContentView()
}
}
}
我想你可以调用这个代码,而不是在UIKit生命周期中调用一个应用程序委托类。。。
谢谢Boothosh。您设置了错误的委托方法。选中
launchOptions
参数。
用这个
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}