Generic Network Layer in iOS Development with Swift

Yusuf Demirci
4 min readApr 19, 2020

Problem

Struggling in the network layer when sending requests and parsing responses.

Solution

Applying generic, modular network layer. The solution includes Generic Type, Completion, Singleton, Codable, URLSession and OOP(Object Oriented Programming) terms.

According to most of the mobile developers, the number one subject or layer or structure in mobile development is Network Layer. A lot of mobile applications work online then the Network Layer is the hearth of them. The point is, how can we build a strong network layer against even for complex applications? Let’s find the answer!

What are we going to do?

We are going to build a service manager, request and response classes, a middle layer to communicate between controller and service calls and data models. All are very similar for every developer but the difference is our response classes are generic. Also, the structure is modular and we can extend it easily.

Controller: The view that needs data and where the service call begins.

--

--