My solution to Hacking with Swift’s Checkpoint 9: writing a single-line Swift function that returns a random element from an optional integer array, or a random number from 1 to 100 when the array is nil or empty. I show the challenge, an embedded video, and the finished one-liner...
My solution to Hacking with Swift’s Checkpoint 8: a Building protocol requiring rooms, cost, and estate agent properties, with a protocol extension providing a method that prints a sales summary. My House and Office structs conform to the protocol, each adding its own extra property, and my sample instances show the method in use...
My solution to Hacking with Swift’s Checkpoint 7, which calls for an animal class hierarchy with Animal, Dog, and Cat as superclasses and specific breeds as subclasses. My included Swift code implements the legs property, overridden speak() methods for each breed, and an isTame property set through initializers...
My short Swift exercise solution covers structs and access control: a Car struct stores a model, seat count, and current gear. The gear is protected with private(set) access and can only be changed through my mutating gearUp and gearDown methods that stay within static min and max gear constants...
My notes on day 10 of the 100 Days of SwiftUI course, which covers structs. Having worked in languages where structs are just data containers, I find their methods and properties initially confusing — including a now-resolved question about the purpose of tuples — and demonstrate with sample code how structs are copied as value types while classes are passed by reference. I also note that SwiftUI sample code is built entirely from structs...
My Swift solution to an array-processing exercise: filtering even numbers out of an array of lucky numbers, sorting the remaining values in ascending order, mapping each one to a formatted string, and printing the results one per line using filter, sorted, and map...
My Swift solution to a coding challenge: compute the integer square root of a number between 1 and 10,000 without using the built-in sqrt() function. My implementation uses a brute-force loop and throws custom errors for out-of-bounds input or when no integer root exists, with do/catch error handling shown in the example usage...
A short follow-up in which I note an unexpected benefit of watching CS193P lecture videos: learning how terms are actually pronounced. I had always said “tuple” to rhyme with “cup,” but the videos revealed the correct pronunciation is “too-pull.”..
A short reflection on my time working through the 100 Days of SwiftUI course, where Paul Hudson pairs each topic with both a video and a text explanation. I usually read the text to skim for the Swift-specific parts of familiar material, use the videos when multitasking with a meal, and find that the two versions aren’t identical, which helps when a concept is unclear...
This is my Swift implementation of the classic FizzBuzz exercise. My code loops from 1 to 100, using named booleans for divisibility by 3 and 5 to decide whether to print Fizz, Buzz, FizzBuzz, or the number itself...
I am starting Paul Hudson’s 100 Days of SwiftUI course and will write short daily blog entries to stay motivated, mirroring the course’s social media posting requirement. I acknowledge a history of abandoned blogs but hope the posts may at least help future searchers. My goal for the course is to get a simple, minimally useful app published on the App Store...