Tag: SwiftUI

  • Sharing is caring

    Continuing on with the demo project from yesterday, in which we used the ImageRenderer class to turn a view into an image, today we want to let the user share it somehow. Typically, apps have a button using the square.and.arrow.up SF Symbol to share something from the current screen. It’s probably not an accident that…

  • ImageRenderer()

    ImageRenderer() is a SwiftUI class that creates an image from a view. You just initialize it with the view, then extract a cgImage (Core Graphics) or uiImage that can be cast to a SwiftUI Image. I’ll need a view to work with, so here it is; a crude version of my behaviour ticket. Here it…

  • SwiftUI provides

    A few hours after I speculated about pausing work on the tickets app because outputting the tickets was too far out of my expertise, a helpful instance of the Baader–Meinhof phenomenon threw up some help in the form of this tweet from @FloWritesCode. It turns out this was an addition in iOS16 announced at WWDC…

  • Something weird ‘append

    I’m noodling around making sure I understand how Core Data works. Thought I’d start with a master/detail app with an array of structs, then replicate it in a Core Data implementation. I’m using an array of this struct for my data: And I thought this code to load up some sample data was pretty sweet.…

  • Bookworm Challenges

    Another set of challenges for a #100DaysofSwiftUI tutorial app. Project 11 was a book tracking app – the big new thing was using CoreData. Here’s the challenges for it. Right now it’s possible to select no title, author, or genre for books, which causes a problem for the detail view. Please fix this, either by…

  • @Binding – data between views

    In C world, if we want to pass a parameter down into a functional call, and allow the receiving function to change it’s value, we’d pass a pointer to the variable. Something like this: For youngsters, what’s happening is that we’ve set the value of a to 5, then passed the memory address of a…

  • 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…

  • 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…

  • List Apps

    When I was first programming professionally, it wasn’t long before I noticed that there were patterns to the sort of bread-and-butter things I was writing most times – the majority of the small business applications I wrote tracked several entities; for each entity there needed to be add/edit/delete screens, there would be some business rules…