buildOptional(_:)
Produces an optional scene for conditional statements in multi-statement closures that’s only visible when the condition evaluates to true.
Declaration
static func buildOptional(_ scene: (any Scene & _LimitedAvailabilitySceneMarker)?) -> some Scene
Discussion
Conditional statements in a SceneBuilder can contain an if statement but not an else statement, and the condition can only perform a compiler check for availability, like in the following code:
var body: some Scene {
if #available(iOS 16, *) {
WindowGroup {
ContentView()
}
}
}