Swift Currency App (Part – 1)

Hello friends. In this article, we will release the same applications using different architectures on iOS level with you. For this, we first need to find a theme. I thought the currency application might be good for this. Then we will have to make a design. For this there will be a simple listing page and then an application that shows the type of the chosen install in terms of other currencies.

First, I will explain the processes we will do in each project here. Afterwards, we will learn about how to write applications with MVC, MVVM and VIPER. Since I learned while writing, I may have mistakes. We can correct it together by sending a comment or e-mail. Apart from that, you can find more detailed explanations here. I definitely recommend you to watch them all.

First, we need to open Xcode and create a workspace here. Because we will write the API layer separately. Thus, we can create a more reusable and more testable project. After creating the workspace, we need to create a new project into the workspace. After the new project, we need to add a framework for the API layer. After doing these processes, a workspace like this should be created.

In the API section, we will pull the data over the internet. We will use the https://fixer.io/ site to extract currency data. Of course, we need a token to use this service. We can obtain this token by registering on this site. We will then use Alamofire to pull data from the URL. You need to learn how to use the pod to install Alamofire. This article may give you some information. Frankly, I could not add pods to multiple projects here. Instead I added Alamofire with Swift Package Manager. You can find an article about it here. After adding this framework, we can start pulling data from the service.

First, we must model the data from the service in order to properly receive and use it. There are very good sites for converting incoming data into models. I am using this site. The model I have obtained is like this;

If we get an error on the service side, I’m creating another model for us to handle it.

Finally, I do the data extraction process from the service. For this, I create a class called Services and pull the data with Alamofire.

When I run the service I see it works fine.

In the next article, we will display the data coming from the service on the screen with MVC architecture.

If you have questions, you can reach by e-mail or comment. Good work.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.