Hi
In C#, one can define associated functions by the following. Notice that "Declarations DE" is a reference to a function in another C# project file. This lets the compiler know that there are other references in the project.
Likewise, "Form_Load" is the entry point of the code, similar to "main" in C. Any calls to related functions can be made in this section, to the functions that have been previously defined above.
So I set out trying to find similar information about SwiftUI, and found several, but only offer partial answers to my questions.
The YouTube video...
Extracting functions and subviews in SwiftUI | Bootcamp #20 - YouTube
... goes into some of the details, but still leaves me hanging.
Likewise...
SOLVED: Swift Functions In Swift UI – SwiftUI – Hacking with Swift forums
... has further information, but nothing concrete that I am looking for.
Now in the SwiftUI project, I tried this...
The most confusing thing for me, is where is "main"? I found several examples that call functions from the structure shown above, BUT I have no reason as to why.
So one web example on StackOverFlow called the function from position 1. That did not work. Position 2 worked to call the function at position 3, but really, why?
All this activity brings up a lot of questions for me, such as:
-
Does SwiftUI need function callouts similar to C#, and they are called out even before running "main". I seem to recall Borland Delphi being this way as well.
-
How does SwiftUI make references to other classes (places where other functions are stored in separate files)?
-
Does SwiftUI actually make use of "main" in the normal sense, i.e. similar to C, C#, Rust and so on?
I did notice that once a SwiftUI function is called, it makes reference to data being passed very similar to other languages, at least for the examples I found.
Note that I looked at official SwiftUI documentation, but did not come across information that answers the above.