Posts

Showing posts with the label optional chaining

Lynda Course - Swift 5 Essential Thinking (Part 6)

Image
Here we go! A quick session now. Not sure how long I've got but gonna do a bit. A couple more chapters of this course, then will review what else from Lynda is worth looking at. At some point I need to decide if the subscription is worth it.  Start Time - 12:57 6. Classes, Structs and Beyond So I looked at the initial couple of videos last time about value vs reference types. Now the focus is specifically on classes. Classes All this is fine - just a recap - class Adventurer {          var name: String     var maxHealth: Int               var specialMove: String ?          init (name: String , maxHP: Int ) {         self . name = name         self . maxHealth = maxHP     }          convenience init (name: String ) {         self . init (name: ...

Lynda Course - Swift 5 Essential Thinking (Part 3)

Image
So, predictably, it's been tough finding time this week. Knew it would happen with work becoming busier! So a quick-ish entry now. Next bit of Swift Essentials! Start Time - 20:46 4. Application Control Flow I love this! Probably my favourite aspect of Swift. Got enough time to complete this chapter as it's a short-ish one. var hp = 91 var maxHP = 100 // If statement (<, >, <=, >=, !=, ==) if hp < maxHP {     print ( "Health is lower than the max health!" ) } else if hp <= 50 {     print ( "Health is running seriously low!" ) } else {     print ( "Health is not registered" ) } Optional Binding   One interesting point is that the temporary value is only available within the if/let statement, not outside of that scope though! Another example with multiple values. Optional chaining -  if let _ = isShopOpen , let searchedItem = blacksmithShop [ "Shield" ], le...

Angela Yu Xcode 12 Course - Part 15 (lectures 167 to 168)

Image
As I mentioned enough times already, this is a tough chapter! Before, when I attempted it (when was that, October/November?) I actually bailed on it. I felt the need to go over the fundamental coding concepts again and that the Clima project was too 'out there'. However, I'm looking at it differently now - it's a great opportunity to see something completely different! And there are some good bits along the way! Start Time - 17:55 Delegates and Protocols I've seen these before - it's about modelling behaviour and about getting something else to do a job essentially! In the context of Clima, the CLLocationManager is the delegate to do the job of looking for the location (for the location manager). Right so seeing it another way - a protocol is a contract! We have drawn up a contract - if it wants to be the delegate, then it needs to be able to handle what is in the protocol created - protocol ChangeCityDelegate {     func userEnteredACityName(cit...

Bob Lee Course Part 9 (Consolidation of chapter 1 - lectures 1 to 15!)

Image
Yes, it's time for some consolidation baby! I could just do so for the past few lectures but it makes more sense to go through chapter one in its entirety. If anything does seem really familiar, that's fine - I will obviously spend less time on that! OK, here we go! Start Time - 17:35 Lecture 1 - Course Overview (skipped!) Lecture 2 - Introduction Key tip to takeaway from this summary is NOT just to click on the 'fix errors' when the 'red' errors come up. They can lead to more errors and mess up the code - then be impossible to track back and sort out! Lecture 3 - Optionals So the big question here is WHY use optionals in the first place. Something to remember here is that Swift is the only language (well, one of the very few at least) that uses optionals. They are a great feature! *Right, rather than play the videos again, I am actually going to use Bob's lecture notes from here: https://www.bobthedeveloper.io/course/swift/1000-swift-fundame...