I've figured it out. You use UIApplicationDelegateAdaptor for iOS, NSApplicationDelegateAdaptor for Cocoa.
import SwiftUI
@main
struct MyCrazyApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: UIResponder, UIApplicationDelegate {
let fileManager = FileManager.default
}
In this fashion, you will access to fileManager in AppDelegate inside another View.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: