Day 12 (part 2 of 4) of 100 Days of Swift

Days 1 to 12 of the “100 Days of Swift” course make up the “Introduction to Swift” section.

Day 12‘s lesson covered optionals, unwrapping, and typecasting. Day 12 is divided into 10 sections with a section 11 being the lesson summary.

I almost didn’t work on “100 Days of Swift” today because unplanned events came up that took over the time slot period that I had originally set aside for Swift study. Ultimately, I decided to complete a lesson section or two instead of zero sections for today.

Thoughts about Day 12

Today’s study session picked up from yesterday’s uncompleted study session. Day 12 contains 11 sections, with many of those sections needing me to do repeat readings in order to grasp the concept being presented.

The background music for today’s study session was streamed from YouTube and titled “Focus Music, Binaural Beats Concentration Music for Studying, Super Intelligence“.

My Day 12 (part 2 of 3) notes taken from my paper notebook

  1. Section 4– Force unwrapping
    • use force unwrap only when you’re sure it’s safe to use.
    • you should never force unwrap something that will not succeed 100% of the time.
    • from Optional reading: there is a link to a post by Alexandre Colucci about avoiding force unwrapping. Read Colucci’s post after completing all of Day 12’s study materials.
  2. Section 5 — Implicitly unwrappped optionals (IUO)
    • implicity unwrapped optionals (IUO) don’t need to be unwrapped in order to use them.
    • IUOs are created by adding an exclamation mark ! after the type name.
    • IUOs don’t need the if let or guard let because IUOs behave as though they were already unwrapped.
    • IUOs are primarily need for UiKit user interface.
    • IUOs are not needed nor used by the SwiftUI framework.
  3. Nil coalescing
    • Nil coalescing unwraps an optional and returns the value inside if there is one. If there isn’t a value (i.e. the optional was nil) then a default value is used.

Today’s total study time: 1 hour 30 minutes

100 Days of Swift cumulative study time: 34 hours

[Note: those are actual study time values after subtracting break-time minutes from the Day’s study session]