In swiftUI, in order to conform to the View protocol, the conforming struct has to implement the body property (specifically, its getter, since body property is read-only).
Can I change the name of body property to something else, say presentation?
struct ContentView: View {
var presentation: some View {
Button("Hello SwiftUI!") {
}
}
}
This doesn't work. I get 'Type 'ContentView' does not conform to protocol 'View'.
In UIKit, when conforming to the UIApplicationDelegate protocol, I was able to change the name of the UIWindow variable. The documentation has the name 'window', but when conforming, I changed it to mainWindow and things worked.
Why can't I change the name of body property of a swiftUI view? Am I missing something?