My second iOS app: Random Dog

Tuesday, November 2, 2021

Who doesn't like looking at pictures of random dogs?

That's why I made Random Dog, my second iOS app, now available on the App Store.

undefined

What is Random Dog

Random Dog is an app that shows you... random dogs. As you're browsing, you can't help but click on the heart-shaped button to keep track of your favorites. You can also filter dogs by breed to focus on the ones you really like. View all of your favorites in one spot, but also check out the Insights tab to see a list of your top favorites.

This app is able to show random dogs through the Dog.ceo API. They have all the dog breeds and dog images. Random Dog simply asks for random pictures.

My friend Ramzi whipped up the logo and app icon.

In my post about The Simple Chess Clock (my first iOS app), I noted a few things that I wanted to learn next. With Random Dog - another learning project - I was able to tackle some of them:

SwiftUI

I created Random Dog using SwiftUI, Apple's modern, declarative framework for developing apps across all Apple devices.

As someone who has worked in front-end web development for a few years now, I found SwiftUI very easy to work with and familiar because it follows similar patterns to the modern JavaScript UI libraries, such as React and Vue.

In direct comparison to the way I made The Simple Chess Clock, which was made using UIKit, I found the SwiftUI way of developing much more enjoyable. It was mainly due to the similarities with React. There are also good APIs for the framework's state management mechanisms - @State, @ObservedObject, and @EnvironmentObject, etc. -  which have made reasoning about the app's state and data more predictable.

If one of the most influential companies on the planet follows a UI paradigm already prevalent in web UI frameworks, that tells you that the declarative "component" concept for UI and associated hierarchy is established and here to stay. 

undefined

Swift

I was able to focus more attention on leveraging the strengths of the Swift language this time around. Leveraging SwiftUI's state management mechanisms (mentioned above), I was better able to implement classes and structs that de-coupled the data model from the View layer. Enums, initialization, and inheritance started to feel like second nature pretty quickly.

Between TypeScript - which I am using a lot more with JavaScript projects - and Swift, I've developed a greater appreciation for thinking first and foremost about data before I build an application.

undefined

Networking/API calls

I still think that the way API calls are made in iOS is a little clunky. Perhaps there is a library that provides a nice wrapper that would be more enjoyable. I guess that's next to find out!

This experience enhanced my appreciation for well-structured and predictable APIs. Dog.ceo is what makes this app fun.

Data persistence

I used a new form of data persistence this time around.

Last time I used the .plist file.

This time, it was the built in UserDefaults, which provides an API to save simple data associated with the app. When you close the app and re-open it, your "favorites" (i.e. the data) are still there. If you delete the app, the data is destroyed as well.

Git

I'm going to go ahead and cross Git off the list. I used my terminal. git init. You get it.

What I want to learn next

I did this last time, so why not do it again. Since this app has more features, I might implement some of the things from the following list in Random Dog soon:

  • Improving my Swift fundamentals... Yes, keep getting better at Swift
  • Add tests
  • Implementing some authentication/authorization
  • Use more 3rd party packages/libraries
  • More custom styling and animation