Ray Wenderlich First iOS SwiftUI App Course - Part 1
So on holiday in the beautiful, tranquil Wora Burra hotel in Hua Hin, Thailand. What better to do than a bit of coding?! Honestly, I love doing this and it is not in any way a chore. I just wish that I could sustain some sort of momentum with it. Life - work mostly - manages to get in the way. OK, we're back to the first app course. This time with the actual UI stuff! Let's get into it.
Start Time - 10:57
OK slight snuggle - Xcode beta needs to install additional components... Just going to watch then pause at the point I need to.
So one of the benefits of SwiftUI is the 'live' update to what the interface looks like. It is on pause by default but can be played easily. This is cool - it means that you don't have to test on the simulator every single time!!
You can still choose a simulator to run it on. This is separate from the live update of UI.
OK Xcode updated, ready to go! I've loaded the Bullseye file from several weeks ago.
Neat little trick - command + tab - lets you switch between applications more easily, rather than looking for the icons on the dock.
Right back to the app... Command and click, then select as view inspector. There you can play around a bit!
This is cool!

You can play around with the properties etc. here. You can do the weight, font, colour etc...
So the SwiftUI Canvas is EASIER than coding all of this.
Objects, Data and Methods
So these are the three core principles of object-oriented programming.
This is mostly recap so not going to make many notes.

Just a reminder that all of these count as objects.
Objects have data (e.g. colour, height view etc.) and functionality - what they can do (methods).
A method is a function that BELONGS to an object.
This the default what what was in the 'ViewController' -

ContentView is the data structure. The variable by default is the body, which most conform to some View protocol. the VStack is again a default for what the text displayed is.
The change in fontWeight and foregroundColor are both methods. These were created via the changes on Show View Inspector.
Buttons and Actions
So the code for button is now within that body view. Different! Connecting doesn't seem to be a thing, which is potentially very cool.
Difference with function/method - method is in specific reference to the object.
Print is for the developer only. We know now that it works!
SwiftUI State
Car dashboard analogy. If things are on/off - true or false are booleans. Others that are numeric e.g. speed, fuel level - these are numerics (Int/Double).
Car state - how fast the car is actually moving. Driver action changes the state. If the state and the dashboard are not in sync - problems! Analogy to mistakes happening in the app.
Cool analogy!
OK, the pop up is not simple - a state value needed first, then something within the button, then the pop up itself. But not that complex when you compare it to how Xcode used to be! The point is that it is all making sense so far.
Solving Problems
All recap - nothing new here.
Coding Challenge!
Trickier than I thought! The snag was to create a SEPARATE @state variable. That's something to ge used to. Rest was fine though.
Done! Finish Time 12:33 (but more like 1 hour 10 mins with interruptions).
A great intro to SwiftUI. The whole point of this course is to get used to the new structure and features. So I'm confident that I'll get there with it. It's good that I wasn't exactly an expert with the former Xcode - so my relearning shouldn't be too bad!
Start Time - 10:57
OK slight snuggle - Xcode beta needs to install additional components... Just going to watch then pause at the point I need to.
So one of the benefits of SwiftUI is the 'live' update to what the interface looks like. It is on pause by default but can be played easily. This is cool - it means that you don't have to test on the simulator every single time!!
You can still choose a simulator to run it on. This is separate from the live update of UI.
OK Xcode updated, ready to go! I've loaded the Bullseye file from several weeks ago.
Neat little trick - command + tab - lets you switch between applications more easily, rather than looking for the icons on the dock.
Right back to the app... Command and click, then select as view inspector. There you can play around a bit!
This is cool!

You can play around with the properties etc. here. You can do the weight, font, colour etc...
So the SwiftUI Canvas is EASIER than coding all of this.
Objects, Data and Methods
So these are the three core principles of object-oriented programming.
This is mostly recap so not going to make many notes.

Just a reminder that all of these count as objects.
Objects have data (e.g. colour, height view etc.) and functionality - what they can do (methods).
A method is a function that BELONGS to an object.
This the default what what was in the 'ViewController' -

ContentView is the data structure. The variable by default is the body, which most conform to some View protocol. the VStack is again a default for what the text displayed is.
The change in fontWeight and foregroundColor are both methods. These were created via the changes on Show View Inspector.
Buttons and Actions
So the code for button is now within that body view. Different! Connecting doesn't seem to be a thing, which is potentially very cool.
Difference with function/method - method is in specific reference to the object.
Print is for the developer only. We know now that it works!
SwiftUI State
Car dashboard analogy. If things are on/off - true or false are booleans. Others that are numeric e.g. speed, fuel level - these are numerics (Int/Double).
Car state - how fast the car is actually moving. Driver action changes the state. If the state and the dashboard are not in sync - problems! Analogy to mistakes happening in the app.
Cool analogy!
OK, the pop up is not simple - a state value needed first, then something within the button, then the pop up itself. But not that complex when you compare it to how Xcode used to be! The point is that it is all making sense so far.
Solving Problems
All recap - nothing new here.
Coding Challenge!
Trickier than I thought! The snag was to create a SEPARATE @state variable. That's something to ge used to. Rest was fine though.
Done! Finish Time 12:33 (but more like 1 hour 10 mins with interruptions).
A great intro to SwiftUI. The whole point of this course is to get used to the new structure and features. So I'm confident that I'll get there with it. It's good that I wasn't exactly an expert with the former Xcode - so my relearning shouldn't be too bad!
Comments
Post a Comment