There are multiple ways.
You can either call your function inside the view via a .onAppear
.
.onAppear {
yourFunction()
}
Or by calling an initializer between the class/struct
you have, and its var body: Some View
as this:
struct YourView: View {
init {
yourFunction()
}
var body: some View {
//Your view code...
}
}
I suggest reading the Swift documentation for a better understanding on these concepts.
solved Start function not being called swftui [closed]