100 Days of SwiftUI
Day 21 had us building a mini flag-guessing game, but without the score implemented. I will be absolutely shocked, shocked I say when we implement the score as the next day’s challenge. 🇺🇸 🇺🇦 🇪🇸 #100DaysOfSwiftUI

Day 20 is all about stacks, gradients, buttons, and images. I find it more fun to keep all the sample code in one project and let it pile up. 🤪 #100DaysOfSwiftUI

Day 19, very fun to have a day focused on building a new app from scratch! This was my take on the challenge. #100DaysOfSwiftUI

Day 18 is a short quiz and adding some new code on our own without any guidance—it took so little time (9 minutes 😝) that I’m tempted to just start on the next day, but I will resist! #100DaysOfSwiftUI
This definitely trips me up:
Tip: It’s tempting to think that modifier should be attached to the end of the
NavigationStack
, but it needs to be attached to the end of theForm
instead. The reason is that navigation stacks are capable of showing many views as your program runs, so by attaching the title to the thing inside the navigation stack we’re allowing iOS to change titles freely.
I’m not sure I 100% understand the reasoning here… excited to learn more. It’s still only day 17! #100DaysOfSwiftUI
Day 16, starting off with creating a new iOS app in Xcode and seeing everything that’s changed since I last used it almost 12 years ago. Hitting Run for the first time… ah it’s so exciting! #100DaysOfSwiftUI
Day 15 is a review of the last two weeks of material! #100DaysOfSwiftUI
I kept on going back to the individual pages to find the syntax I needed while working on the tests, so I’m happy to have it all on one page: www.hackingwithswift.com/articles/…
Day 14 is optionals, guards, nil coalescing, optional chaining, and optional try.
Guards are new to me but I like them:
func double(number: Int?) -> Int? {
guard let number = number else {
return nil
}
return number * 2
}
Two weeks in the books! #100DaysOfSwiftUI
Prototypes, opaque return types, extensions, and protocol extensions don’t have equivalents in JavaScript (and my TypeScript isn’t good enough to compare Swift to TS), but these concepts were straightforward enough that I breezed through day 13. #100DaysOfSwiftUI
copies of the same class share their underlying data, meaning that changing one changes them all, whereas structs always have their own unique data, and changing a copy does not affect the others.
I found this explanation confusing until I took the test and realized the difference.
In JS, creating an object or class instance and assigning it to two different variables matches the “copy” semantics above (the variable is a reference to the object).
The “struct” behavior (by value) is how primitives work in JS (string, bool, etc.). Objects never work this way.
Day 12 over! #100DaysOfSwiftUI
Structs, mutating
on methods, computed properties, property observers, custom initializers… it’s a lot but it was pretty easy to get through.
I think the only “new” concept (coming from JavaScript) was marking methods as mutating
.
Day 10 done so 10% of the way there! #100DaysOfSwiftUI
Dropping the parenthesis when calling functions with a closure blows my mind:
team.filter { $0.hasPrefix("T") }
The equivalent in JS:
team.filter($0 => $0.startsWith("T"))
Woo! The checkpoint test actually didn’t take me very long to complete.
Day 9 in the books! #100DaysOfSwiftUI
Really interesting that Swift has do
, but it’s not what you think!
do {
try throwingFunction1()
nonThrowingFunction1()
} catch {
print("Handle errors here")
}
In JS, that do
would be try
and no “try” is required before a throwing function.
Day 8 in the books! #100DaysOfSwiftUI
Awesome to me that this is valid:
func record(age: Int) { }
func record(year: Int) { }
Naming internal and external parameters separately is interesting too:
func square(of num: Int) -> Int {
return num * num
}
let result = square(of: 4)
Day 7 in the books! #100DaysOfSwiftUI
Day 6 is all about for
and while
loops.
I’ll be excited to learn the .map
and .filter
equivalents. I rarely use for
loops in JS and have only used while
a couple times in my career. 🫢
I wasn’t expecting to do FizzBuzz for the checkpoint test. There’s a first time for everything! #100DaysOfSwiftUI
No ===
in Swift (just ==
) is nice!
Enums being comparable is pretty cool too.
And switch
statements… is this the day I confess that I tend not to use them in JavaScript? Swift’s fallthrough
syntax seems much safer than JS needing a break
for each case
.
Day 5 done! #100DaysOfSwiftUI
This is really interesting:
let name: String
// …
name = "Chasen"
// Allowed once
In JavaScript, the “equivalent” (using const
) requires an initial value and doesn’t let you reassign it later. I like that Swift allows it be undefined and assigned just once.
Day 4 done! #100DaysOfSwiftUI
Coming from JS, there are some small differences in array and dictionary syntax. This really stood out to me (as nice and explicit):
let olympics = [
2016: "Rio de Janeiro",
2021: "Tokyo",
2024: "Paris"
]
print(olympics[2020, default: "Unknown"])
Day 3 in the books! #100DaysOfSwiftUI
This has a bug… can you spot it?
let temperature = 29
let converted = (temperature * 9 / 5) + 32
print("Celsius: \(temperature)")
print("Fahrenheit: \(converted)")
I thought the compiler might warn when losing precision like this, but I guess not!
Day 2 in the books! #100DaysOfSwiftUI