-
-
Save sturdysturge/fe38d736d099177838698268593ef68e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| protocol MyView { | |
| associatedtype Body : View | |
| // Apple adds @ViewBuilder here in the View protocol | |
| var body: Self.Body { get } | |
| } | |
| struct ConformingView: MyView { | |
| // @ViewBuilder needed because multiple values are returned | |
| @ViewBuilder | |
| var body: some View { | |
| Text("One") | |
| Text("Two") | |
| Text("Three") | |
| } | |
| // @ViewBuilder not needed because type is inferred to be | |
| // Group<TupleView<(Text, Text, Text)>> | |
| var oneConcreteType: some View { | |
| Group { | |
| Text("One") | |
| Text("Two") | |
| Text("Three") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment