SwiftUI/Protocol/App: Difference between revisions

From Azupedia
Jump to navigation Jump to search
imported>Fire
No edit summary
 
(No difference)

Latest revision as of 10:33, 6 November 2022

App
Typeprotocol
iOS14.0+
iPadOS14.0+
macOS11.0+
MacCatalyst14.0+
tvOS14.0+
watchOS7.0+
Websitedeveloper.apple.com/documentation/swiftui/app/

アプリの構造や動作を表す。 Settingsは、Macで有効。

@main
struct Mail: App {
    @StateObject private var model = MailModel()

    var body: some Scene {
        WindowGroup {
            MailViewer()
                .environmentObject(model) // Passed through the environment.
        }
        #if os(macOS)
            Settings {
                SettingsView(model: model) // Passed as an observed object.
            }
       #endif
    }
}

External Link

【SwiftUI】Appプロトコルのリファレンスを読む