A Flask Blog Application API

In these series of posts, I will take you through the design, development, testing, documentation , deployment and maintenance of a blog application back-end hosted on Heroku.We will add a react…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




AppVersion Model

There are a variety of features that depends on app version:

As you might know, we can get app version from Bundle info dict:

There are several inconveniences in this approach:

1. We are forced to use if-let construction every time we need to get app version or use nil coalescing operator

2. Repeat boilerplate code: Bundle.main.infoDictionary?[“CFBundleShortVersionString”] as? String

3. Repeat boilerplate code to extract major / minor / patch components:

4. No ability to correctly compare two versions. Let’s see an example:

This is our improvement plan:

☐ get rid of meaningless if-let constructions or usage of nil coalescing operator

☐ get rid boilerplate code to get app version from Bundle’s userinfo

☐ get rid boilerplate code to extract major / minor / patch components

☐ add an ability to correctly compare two versions

Let’s try to fix all these minuses. First of all, we improve the standard Foundation Api:

First two items are completed:

☑ get rid of meaningless if-let constructions or usage of nil coalescing operator

☑ get rid boilerplate code to get app version from Bundle’s userinfo

Very good, let’s go further.

Now, we create an AppVersion model:

Next step is to make full implementation:

Next step is to make AppVersion comparable:

One more optional step is to make it Codable. In my case it is needed, but you can omit this.

Finally, we add two additional static properties to Bundle extension:

Besides, we can store the app version of the previous launch:

Let’s see the result:

All goals are achieved: 💪🏼

☑ get rid of meaningless if-let constructions or usage of nil coalescing operator

☑ get rid boilerplate code to get app version from Bundle’s userinfo

☑ get rid boilerplate code to extract major / minor / patch components

☑ add an ability to correctly compare two versions

Add a comment

Related posts:

Remote Lightning Decision Jam using only Google Presentation and Skype

Since it was first described by Jonathan Courtney, CEO of AJ & Smart, back in 2017, this exercise has been widely used by a vast range of companies and teams to solve almost any problem, with the aim…

Buried Truth

The masked face must never fake, the outcome has nothing to hide. Smile through the reason to reveal. Buried the love as suicide ideas matured. Buried the ignominy as sorrow shattered the…

What meetings are required for Agile app development?

Development sprints are when the app gets coded. There are different methods to actually code every given piece of functionality (which leads to great variability in app quotes you may have seen). We…