Category: Swift5.7

  • Cupcake Corner challenges

    Day 52 of #100Days was the challenges to the Cupcake Corner app – an app that allows you to build a one-row order, encode it as JSON and submit it to an API with a URLSession. To allow the order to be passed around, it’s an @ObservedObject which meant that a few extra hoops needed…

  • Codable when the keys don’t match

    A common issue when working with JSON that you vacuum up from internet APIs will be that the key names in the JSON don’t match your property names. The JSON de facto standard of using snake_case in key names could be one cause, or perhaps you just take variable naming more seriously than the person…

  • Codable & JSON

    If we mark a type with the protocol Codable, we’re specifying that this type has the capability of having it’s properties encoded to some format, and decoded back again. So far in the #100Days this has been used to write and read data in UserDefaults, and to encode an object to send it as a…

  • Day 50 – @State vs @Observed again

    Way back when, I was unclear about @StateObject and @ObservedObject (here, and here). I still am. But in today’s tutorial video, Paul clearly says that the @StateObject is for the single place in your app where the object is created, then everywhere else, use @ObservedObject. Trouble is, I just know from the Simple MVVM app…

  • Day 47 – Habits App

    I’ve been mucking around with the Habits app too long – it’s started to look like procrastination. It already meets the specification, so I’m calling it an MVP and moving on. This is the first app of mine I’ve loaded onto my phone and started using, and there are a couple of things I’d like…

  • JSON encode/decode

    As usual, I’m spending way more time on the apps written from scratch in the 100Days series. The Habit tracking app I’m working on has been good practice, especially of the architecture of the simple list based app. My version has a couple of refinements I quite like. I’m using a checkmark in a rectangle…

  • Refreshing SwiftUI Views

    SwiftUI does some property wrapper magic to (very efficiently) refresh your views, but what if you want to force a refresh for some reason? Here’s the techniques I’m currently using to do that. The tricks are below, but just so you can see them in context, here’s the sample app we’re working on. It’s a…

  • You need to enjoy puzzles

    I’m writing the Habits list based app from #100Days and had a working MVP, then for some reason, decided to refactor by changing the subview I’d written as a function, into a struct. Some time later, I discovered that my list items were not updating correctly, so detective time. I talked a little bit about…

  • Purple warning – “Publishing changes”

    It’s a pretty safe bet that if Xcode is saying there’s an error in my code, that it’s correct, and I am in error – not Xcode. Today I came across a situation where that might not be true. I think the purple warnings are problems detected at runtime – I’ve heard of thread problems…

  • Drawing Feedback

    Here’s the summary of my learning from comparing my efforts with Paul’s solutions to the Project Nine challenges from Day 46 of his 100 Days of SwiftUI course. Create an Arrow shape – having it point straight up is fine. This could be a rectangle/triangle-style arrow, or perhaps three lines, or maybe something else depending…