1
var body: some View {
    Form{
        Text("Hello, World")
    }
}

At this code, what this code

 Form{ Text("Hello, World") }

means? Is this creating an instance of the 'Struct Form'? or is it creating an instance of 'Struct Form' and just adding a closure? or do I have to just call it function builder?

Seungjun
  • 874
  • 9
  • 21
  • Are you asking about how does the weird-looking syntax you use in SwiftUI work? – Sweeper Feb 21 '20 at 08:25
  • [What enables SwiftUI's DSL?](https://stackoverflow.com/q/56434549/1187415) – is that what you are looking for? – Martin R Feb 21 '20 at 08:30
  • Yeah, Kind of, I know how using From affects View but I got no idea what that weird-looking one exactly is. – Seungjun Feb 21 '20 at 08:33

1 Answers1

2

It is calling of Form constructor

/// A container for grouping controls used for data entry, such as in settings
/// or inspectors.
///
/// - SeeAlso: `Section`, which can be used to add sections between groups of
///     content.
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
public struct Form<Content> : View where Content : View {

    public init(@ViewBuilder content: () -> Content)

so

Form{ Text("Hello, World") }

is equivalent of

Form.init(content: { () -> Text in
    return Text("Hello, World") 
})
Asperi
  • 228,894
  • 20
  • 464
  • 690