blog.iankulin.com

100daysofswiftui

Times Tables -Day 35 Challenge

My write-up of the Day 35 challenge from 100 Days of SwiftUI: building a times tables drilling app. I cover creating a custom number keypad and replacing the standard iOS modal with a ZStack-based overlay, finding that tap events pass through very transparent overlays but not more solid ones. I also note the finished app is plain-looking and that improving visual design is now a goal...

User Defaults & Horizontal Pickers

Day 35 of the 100 Days of SwiftUI challenge, which I spent building a multiplication tables drill app for kids. I cover persisting the user’s table selection with UserDefaults (including an enum to avoid hard-coded key strings and a fallback for missing values), plus a Stack Overflow trick for building a compact horizontal wheel picker using paired rotationEffects...

Ranges

A follow-up to my previous post about the difference between writing a SwiftUI ForEach range as 1..<21 versus 1…20. I found the answer in a Hacking with Swift Day 34 article, which indicates older versions of Swift might not have allowed the closed-range form...

Animating Guess The Flag

This is a write-up of Project 6 of 100 Days of SwiftUI, which adds animations to the earlier Guess the Flag app. The tricky part was that all three flags are built in a ForEach, so animations applied to every button at once; the fix was storing each flag’s animation magnitude separately and animating unclicked flags by zero. I also cover re-animating the flags once the alert closes, along with my criticism of the tutorial’s alert UI...

Animation Feedback

A short comparison of two solutions to the Guess The Flags animation challenge: my approach of storing animation amounts in an Int array versus Paul’s more concise use of ternary operators in the modifiers. Both vary the effect depending on which flag was selected, but Paul’s version needs considerably less code...

Project 5 - Word Scramble

I built a Scrabble-like word game as a 100 Days of SwiftUI project. I cover bundling a large text file and loading it into an array at view launch, plus a brief detour into UIKit to use UITextChecker. My source code is on GitHub...

Word Scramble Feedback

After finishing the Word Scramble challenges in Hacking with Swift’s 100 Days of SwiftUI, I review Paul Hudson’s subscriber-only solution and pick up two improvements. The first is a clearer way of resetting the used-words array; the second replaces my bottom-toolbar score display with a safeAreaInset that initially seemed overcomplicated but looked better in practice...

Project 4 Challenges

I complete the Project 4 challenges of the 100 Days of SwiftUI course and compare my solutions to Paul Hudson’s video solutions. Differences covered include Section header syntax, a picker implementation containing a careless bug, and moving a bedtime calculation into a computed property. Finding the comparison useful, I plan to check the video solutions going forward...

Machine Learning

Reflecting on how a Tom-Tom GPS once seemed to predict my destinations, I work through Day 27 of 100 Days of SwiftUI, which covers CoreML by training a model in CreateML from Xcode and using it in an app. I note how straightforward the process was and that I’m more excited about small uses of machine learning, like better defaults for user inputs, than ambitious applications. I link to Apple’s machine learning introduction...

Rock, Paper Scissors (2)

A follow-up to my SwiftUI rock-paper-scissors app built under deadline, working through the improvements noted at delivery. I replace array-and-int game logic with a Swift enum, consolidate separate win/loss checks into a single gameResult function returning a win/loss/draw type, and swap duplicated .hidden() views for an .opacity modifier with a ternary, cutting the view body from 74 lines to 52...

Rock, Paper, Scissors (1)

A working SwiftUI version of the Hacking with SwiftUI Day 25 project, a Rock, Paper, Scissors game where the player must randomly try to win or lose each round. I share the full source code and list aspects of the implementation I’m unhappy with, such as the array-and-int game state, duplicated win-checking functions, and a hidden-view layout workaround, and note the scoring deviates from the project brief...

.self in ForEach

While working through Hacking With SwiftUI, I run into two points of confusion around ForEach: what the id: .self key path actually does when looping over an array of strings, and a compiler warning about non-constant ranges such as 0..<agents.count. Attempts to use key paths directly don’t compile, and a forum explanation of the warning — guarding against the array changing size during the loop — leaves me unconvinced...

Project 3

My solutions to three small SwiftUI challenges: using a ternary with semantic colors to turn the total red at a 0% tip in WeSplit, wrapping the flag Image in a reusable FlagView for GuessTheFlag, and building a custom ViewModifier with a View extension that applies a large blue title style. Each solution includes a short code snippet and a link to my change on GitHub...

Day 23 - Views and Modifiers - Part 4

A SwiftUI tip on decomposing views by extracting them into custom View structs that accept values at initialization, illustrated with a reusable padded green text component. I favor this approach because such building blocks are portable and can be used in other views...

Day 23 - Views and Modifiers - Part 3

A look at how I decompose SwiftUI views into smaller pieces: storing view fragments as properties, why properties can’t reference each other, and why a computed property can’t return multiple views without a single container. I cover fixes including wrapping views in a VStack or Group or applying the @ViewBuilder attribute, and I note a quirk where omitting a VStack unexpectedly produced two preview instances...

Day 23 - Views and Modifiers - Part 2

A short SwiftUI note in which I compare two ways to vary a view based on state: branching with if/else inside the body, which Paul Hudson warns makes SwiftUI destroy and recreate views when the state changes, versus using the ternary operator within a modifier so only the changed property updates. I walk through both code versions and reflect on why the efficiency difference exists...

Day 23 - Views and Modifiers - Part 1

I give an introduction to SwiftUI views, explaining that views are immutable structs with a body property that SwiftUI renders automatically rather than being drawn manually. I cover container views like HStack and the use of modifiers such as padding and frame, including how modifiers on a container apply to its children and why their order affects the result...

Project 2 - Guess the Flag

The second tutorial project in my 100 Days series, a flag-guessing game written with everything in the view — an approach I grew uneasy with as the challenges expanded it. Takeaways include string-based image asset identification, alert dialogs in a declarative framework, and gradients and frosted glass effects. Source code is on GitHub...

Challenge 1

I built a simple unit conversion app for Challenge 1 of Day 19 of 100 Days of SwiftUI, deliberately keeping it minimal without MVVM. New techniques I covered include limiting the keyboard to numbers and adding a toolbar to dismiss it. I also note that SwiftUI text fields don’t select existing text for overtyping, with no straightforward fix short of a third-party package, and I include full code plus a GitHub link...

$==Commitment

I cover Paul Hudson’s free 100 Days of SwiftUI course and the paid Hacking with Swift+ subscription option. I signed up for a year to support Hudson’s contributions to the Swift community and because the one-year time limit makes it more likely I will complete the course...