blog.iankulin.com

Swiftui

Sharing is caring

Continuing my SwiftUI demo project, I use ShareLink to let users share a view rendered as an image via the standard share sheet, with SharePreview supplying the thumbnail and title. I also cover adding the Photo Library Additions usage description so a Save Image option appears, along with the permission prompt users see on first use...

ImageRenderer()

A short SwiftUI example showing how ImageRenderer converts a view into a UIImage or CGImage. I build a simple behaviour ticket view, use a Save button to render it to an image, and display the saved result behind a toggle...

SwiftUI provides

After nearly shelving my SwiftUI tickets app over concerns that exporting tickets was beyond my expertise, I discover an iOS 16 feature that makes the task straightforward, plus existing code examples for rendering SwiftUI views to PDF. The post reflects on the lesson of investigating before assuming something is hard, and notes remaining work on layout and share behaviour...

Something weird 'append

A debugging story about a SwiftUI master/detail list where every row displays the first record’s data. While preparing to replicate my app in Core Data, I work through Swift’s value-type semantics, a Playground experiment, and print debugging before finding the real cause: mutating and reusing a single struct created duplicate UUIDs that broke ForEach, despite a console warning early on...

Bookworm Challenges

My solutions to the Project 11 challenges from the 100 Days of SwiftUI course, applied to Bookworm, a CoreData-based book tracking app. I add validation so books can’t be saved without a title or author, highlight one-star ratings in the book list, and add a date attribute to the Book entity that’s formatted in the detail view...

@Binding - data between views

I explain SwiftUI’s @Binding property wrapper, framed by an analogy to passing pointers in C. A short code example demonstrates a parent view passing an @State variable to a subview with the $ prefix, letting the subview read and mutate the value...

Cupcake Corner challenges

My solutions to the day 52 challenges for the Hacking with Swift Cupcake Corner app: trimming whitespace before validating the order address, showing an alert when the order submission to the API fails instead of just printing, and converting the Order class to a struct inside an ObservableObject wrapper to eliminate the manual Codable code. I present each change with Swift code snippets and links to the corresponding GitHub commits...

Refreshing SwiftUI Views

Ways to force a SwiftUI view to redraw, demonstrated with a sample app that tracks a list of cars and their counts. The core technique is toggling a @State property that gets passed into subviews, which I then trigger via pull-to-refresh with .refreshable(), on app activation by watching scenePhase with .onChange, and on an interval with a published Timer and .onReceive...

You need to enjoy puzzles

After converting a SwiftUI subview from a function to a struct, list items in my habit list app stopped updating correctly. Suspecting a value versus reference type issue, I distilled the problem into a minimal ObservableObject example, only to find that both the example and the original app now worked. The post walks through the code and the debugging process but ends without an explanation of what caused or fixed the bug...

List Apps

Reflecting on the Day 47 habit-tracking milestone challenge, I observe that simple SwiftUI list apps follow a common recipe: Identifiable/Codable structs, an ObservableObject collection with @Published state, and a List inside a NavigationView. I outline that pattern, its benefits for building quality apps quickly while staying HIG-compliant, and the risk that such apps end up looking and feeling like every other list-based offering...

Moonshot Feedback

A comparison of my SwiftUI solution to the Hacking With Swift Moonshot challenge against Paul Hudson’s, covering choices like whether to extract sub-views into separate files and using a List versus a ScrollView with HStacks. The key difference I discuss is a toolbar toggle built with a Button instead of an Image with a tap gesture, since using standard controls as intended gives screen readers the information they need for accessibility...

CodeTrimmer - First MacOS App

Inspired by a StackTrace podcast episode about automating small development tasks, I built my first macOS app with SwiftUI: a utility that strips excess leading indentation from code copied out of Xcode, a chore I previously did by hand before pasting code samples into my blog posts. Screenshots show the paste-and-strip workflow, and I found the move from SwiftUI iOS development to macOS nearly effortless. My source code is linked...

Design Challenge

I give a progress update on translating an external designer’s UI into SwiftUI, covering the rounded-rectangle elements I’ve completed and the .offset modifier I used to create an overlapping layout. My remaining work includes a custom picker and a combined picker/progress indicator...

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...

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...

Animations in Views

A short walkthrough of three ways to animate SwiftUI views, written as part of my progress through the 100 Days of SwiftUI series: implicit animation via the .animation() modifier, animation bound to controls like sliders, and explicit animation for coordinating simultaneous changes. Each approach is illustrated with example code and a demo video...

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...

Before SwiftUI

Working through Day 26 of 100 Days of Swift, I watch an iOS Academy video on dates, calendars, and date components. My main observation is how long UIKit and storyboard setup takes before any useful code gets written, prompting my appreciation for SwiftUI and Swift Playgrounds as learning tools...