Content deleted Content added
copyvio section: "SwiftUI provides event handlers for..." Tag: Reverted |
and I got the wrong link, so much for double checking. See previous edit summary. |
||
(6 intermediate revisions by 6 users not shown) | |||
Line 1:
{{Short description|User interface framework}}
{{One source|date=January 2024}}
Line 11 ⟶ 10:
| genre = [[Software framework]]
| license = [[proprietary software|Proprietary]]
| website = https://developer.apple.com
}}
Line 21 ⟶ 20:
SwiftUI integrates with other Apple technologies, such as [[Xcode]] and [[Swift Playgrounds]] to provide for real-time previews during editing,<ref name=":0">{{Cite web |title=Previews in Xcode |url=https://developer.apple.com/documentation/swiftui/previews-in-xcode |access-date=2023-11-07 |website=Previews in Xcode – Apple Developer Documentation |language=en |archive-url=https://web.archive.org/web/20231107221047/https://developer.apple.com/documentation/swiftui/previews-in-xcode |archive-date=2023-11-07}}</ref><ref>{{Cite web |title=Swift Playgrounds |url=https://developer.apple.com/swift-playgrounds/ |access-date=2024-01-31 |website=Apple Developer |language=en}}</ref> alongside support for debugging and other development features.
SwiftUI allows for interoperability with UIKit and AppKit views via the <code>UIViewRepresentable</code>
== History ==
Line 35 ⟶ 34:
== Examples ==
The following is an example of a simple [["Hello, World!" program|Hello World]] program. The {{code|@main}} attribute defines the entry point into the app. It is standard practice in SwiftUI to separate the application struct and views into different structs, according to the [[Model–view–viewmodel|Model–View–ViewModel]] (MVVM) architectural pattern.<ref>{{Cite book |last=Hudson |first=Paul |title=Swift Design Patterns |publisher=Paul Hudson |year=2018 |language=English}}</ref>{{self-published source inline|date=April 2024}}
<syntaxhighlight lang="swift">
import SwiftUI
Line 47 ⟶ 46:
}
}
struct ContentView: View {
var body: some View {
Text("Hello, World!")
}
</syntaxhighlight>
|