I am trying to get access to my TupleView which my ViewBuilder use it to build the content, then I am trying to count it, here I made my codes until this point, I need help to find the count of my TupleView, right now for unknown reason it returns 0, which I was expecting 5! thanks for help.
import SwiftUI
struct ContentView: View {
var body: some View {
ModelView(content: {
Text("Hello, world! 1")
.padding()
Text("Hello, world! 2")
.padding()
Text("Hello, world! 3")
.padding()
Text("Hello, world! 4")
.padding()
Text("Hello, world! 5")
.padding()
})
}
}
struct ModelView<Content: View>: View {
var content: () -> Content
init(@ViewBuilder content: @escaping () -> Content) {
self.content = content
let size = Mirror(reflecting: content).children.count // <<: Here! it returns 0! which must be 5!
print(size)
}
var body: some View {
content()
}
}