blog.iankulin.com

Xcode14-1

ChatGPT's code writing

I ask ChatGPT to write a SwiftUI todo app with items that reoccur after a set number of days, sharing the generated code and the fixes needed to make it run, such as replacing a non-existent date formatter and adding a NavigationView. Iterating toward a more complex app, including CoreData persistence, required progressively more manual correction from me. My brief closing thoughts cover what ChatGPT might mean for developers and internet content...

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

Clean code

After listening to a podcast episode about “humane” development, I describe my personal Swift coding style, which centers on being kind to whoever reads the code next. The principles I cover include following community conventions, writing code that reads like natural language, keeping functions small and single-purpose, avoiding hidden dependencies like globals, and using comments as temporary scaffolding that usually gets deleted once the code is written...

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

Regex to split a string with two different characters

A walkthrough of using Swift 5.7’s regex support as the separator argument to String.split(), in order to parse a string like “Some behaviour (expectation)” into its two parts. I build the expression up step by step, covering escaping of brackets and spaces and the use of the pipe for OR, and note that the Playgrounds app doesn’t yet support Swift 5.7...

FriendFace 61 Feedback

I compare my attempt at a Core Data caching challenge—storing fetched user data so the app can still display it after network failures—against Paul’s model solution. Differences covered include adding a merge policy for handling constraint conflicts, keeping ids as UUIDs, and placing MainActor.run inside the network fetch rather than after it...

61 Done

I complete Day 61 of #100DaysOfSwiftUI, decoding JSON and backing it up into a Core Data graph for display. I get stuck on one:many relationships and an id type mismatch, plus some unexplained Core Data console warnings that linger despite the app working...

Core Data basics – Part Three

In part three of my Core Data basics series, I show how to add a one-to-many relationship so each Garden can have multiple Plants. I cover converting the generated NSSet of related plants into a sorted array via a computed property, displaying the plants in a list in the garden detail view, and linking plant instances to a garden when creating sample data...

Core Data basics - Part Two

Part two of my series on Core Data basics, in which I convert a SwiftUI master/detail garden-list app from structs to Core Data. I walk through defining entities in the Xcode data model, generating editable NSManagedObject subclasses, setting up a DataController with NSPersistentContainer, and fetching and saving data with @FetchRequest. I defer one-to-many relationships to the next part, and I draw much of the code from Paul Hudson’s 100 Days of SwiftUI...

Core Data basics - Part One

In the first part of my series on learning Core Data basics, I build a simple SwiftUI master/detail app that lists gardens and their plants using structs and arrays, as a starting point before converting it to Core Data in later parts. My code draws heavily on Paul Hudson’s 100 Days of SwiftUI course, with a GitHub link to the source...

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

Clean Build Folder

A debugging session I had while adding Core Data to the FriendFace app: build errors from re-declared NSManagedObject classes turned out to be caused by CodeGen left enabled on one of two entities, and a later class-not-found error came from stale generated files Xcode had left in its build folders. I walk through both issues and end with a note that switching CodeGen to Manual doesn’t delete files Xcode already generated there...