Exploring the Structure of a SwiftUI App
Today I started the next lesson from ๐
It was a much softer launch than Landmarks. There, we are instructed to create a new app right away & start experimenting. Here in Section 1, we given some reading on the App, Scene & View protocols, further down we are directed to the Import Declaration & the @main attribute.
One thing I am curious about- are there other App attributes we should know aside from @main? Maybe it’s a silly question but let me write it for us to laugh at later and keep it moving
Section 2 seemed to be shorter than Section 1
They did have Experiment highlights on the side, encouraging followers to make small changes, change the padding parameter values, build and run, and that’s about it. Felt a little underwhelming, as they had us download a sample and officially we didn’t even change it.
Took some time to sit back & read the App protocol documentation.
The App manages the Scenes
The Scenes manage the View
Scenes respond to state changes
State is declared in the app, and it is shared across the Scenes.
A Scene may have one of three phases:
Active, Inactive, & Background
An Active Scene is in your face and we are interacting with it.
Background Scene has our app in the background, we have a phone call or different app in the foreground
Inactive tells us that the app should not receive events, and release memory / caches held
We are getting ready to shutdown and save. Apps would never stay in this state for very long.
In Lesson 2, we are learning about the view hierarchy of a scene. It made me feel a little down how the lesson could have been similar to Landmarks, there we actually have some tasks to accomplish. The whole gist of the lesson would have been stronger had they had us create a file such as MyAlternativeScene and give the learner some driving ability.
Lesson 3 was more reading and felt like it put me back in the learner’s seat instead of feeling like a passenger. Text, Symbols, Labels, Controls, Images and Shapes are introduced to the reader.
Came back around & read up on the Attributes, linking the idea that we could have a macro above a struct, why, and what some others are. Whew! Didn’t read it all, but I did see what they had to say about @main and now it is a bit more clear.