Posts from July 30, 2023

Enums for Managing Multiple User Actions

This is a really interesting article for building large scale SwiftUI apps. There is some sage wisdom here.

The lesson I particularly learnt from the article is enums. They are so handy for when you don’t want to expose your entire view. Additionally, you can avoid using View Models to power your user interactions which makes your view more reusable (something I try to achieve for building SwiftUI previews).

Here is the example that they provide in the article:

struct ReminderCellView: View {
    let index: Int
    let onEvent: (ReminderCellEvents) -> Void

    var body: some View {
        HStack {
            Image(systemName: "square")
                .onTapGesture {
                    onEvent(.onChecked(index))
                }
            Text("ReminderCellView \(index)")
            Spacer()
            Image(systemName: "trash")
                .onTapGesture {
                    onEvent(.onDelete(index))
                }
        }
    }
}

struct ContentView: View {
    var body: some View {
        List(1...20, id: \.self) { index in
            ReminderCellView(index: index) { event in
                switch event {
                    case .onChecked(let index):
                        print(index)
                    case .onDelete(let index):
                        print(index)
                }
            }
        }
    }
}
post

Weeknotes № 2

I promised that I would make a regular series of this, but I’ve been busy coding for the past few weeks. Nonetheless, I plan to release some articles after this one.

Progress on my app is going well. From time to time, I run into roadblocks which frustrates me greatly. However, I am grateful that I am able to overcome them one by one.

I’ve also been working on the business side of things. I registered my Apple Developer account, created some social media accounts for the app and registered a domain name as well. For the former, I have successfully uploaded my app to Testflight. So it’s a matter of actually polishing the damn thing so I can push for beta.

post