SwiftUI – The Best Interface Builder That Wants Me Dead.

I have been spending a lot of time trying to build an interface for a new version of one of my apps. I had a layout that was working visually, but unfortunately SwiftUI wasn’t up to making it work as it should. I have remade it multiple times over the last week in order to get buttons and pickers to work as they should.

Finally, tonight things started to work. I wish I could explain why they didn’t work in the first place, but oh well. It isn’t perfect and I still have a lot of things to add, but it is working.

I really like the idea of SwiftUI. It offers a nice escape from the usual interface builder and the never ending fight with constraints. But, it still has a lot of bugs that need to be squashed before it will really take off.

For me, my two fights were problems deleting pickers in a list, or making the keyboard pop up and work properly with those pickers. Most apps aren’t going to use a collection of pickers that need to be added and deleted, so my problems won’t help many of you. I ended up having to do some odd workarounds to make the delete happen. The keyboard issue kind of fixed itself in the process of attempting a ton of different ideas. I have since cleared out close to 200 lines of code that were added during my attempts to make it work. The most surprising part – it STILL WORKS. Yeah, I’m as shocked as you are.

If you want to develop your app with SwiftUI, go for it – but only if you have some time to work around its internal issues.

Here is a link to a page that answers many basic questions about SwiftUI and also a great rundown of the various features and how to use them: Fucking SwiftUI.

Don’t Let Small Things Stop You From Making Progress.

This one is coming from my own recent experience. I am working on a remake of one of my popular apps – Time Clock Helper. I have some of the basic parts working, but I wanted to add the ability to add multiple punches. The original app could only use four punches at a time with an option to turn off either pair of them. There were some issues with SwiftUI and deleting the punches, but I managed to come up with a work around for that.

The problem that slowed me down over the last few days – to the point that I didn’t really want to look at it until I had an answer was how to handle deleting punches. I originally allowed them to delete any punches they wanted, but that caused some minor issues with my work around for SwiftUI. So, to avoid that issue, I made the first and last punch permanent. That worked well and the user could add and remove punches at will.

The only problem is that it didn’t fully make sense. Why were the punches you added always in the middle and not simply at the end? I struggled with this idea. I liked that idea that the initial punch in, and the final punch out would always be kept in place. But, would that make sense to someone other than myself? I wasn’t so sure about that.

But, today I decided to just leave that problem alone for now and move onto other parts of the app. As I was plugging away, it suddenly became obvious. It was so obvious that I am cringing as I write this – get rid of “Add Punch” and change it to “Add Break.” Boom. Problem solved. A few seconds of coding later I fixed an issue that had been bothering me for days.

If I had simply been able to ignore the small issue and move on a few days ago, I probably would have found the solution days ago and not wasted so much time. Oddly, I thought of this topic earlier today when I didn’t yet have a solution. I was simply going to write about how I ignored the small problems and was able to make progress on my program in spite of the issue. But, I guess I proved my own point in a better way that I would have expected.

A Quick Tool For Parsing JSON Files.

This will be a quick post, but it shows off a website that has the potential to save people a ton of time. I used it for a small project that I was playing with, but I suspect that many of you will find it useful, too.

https://app.quicktype.io/

The page gives many option to create code for parsing JSON files.

Here are just some of the options available.

Once you select your language and other options, it quickly generates the code that you can drop right into your program in order to parse the files. It was quick and easy and made a tedious job simple.

They don’t charge for the service so there is no reason not to use it.