Networking layer tutorial

Hello,

So i just finished the learning path for iOS, and i know a little bit about MVC, but i can’t find a tutorial here with the networking layer described/explained.

Do we have one here and i’m just missing it?

Thanks.

Hi @swiftwitcher, are you looking for a tutorial on networking with Swift? If so, here is a link that displays all tutorials on the topic. Search Results for Networking + Saving Data/Persistence

Best,
Gina

1 Like

Hey,

Thanks for the reply. No i’m not looking for a tutorial on how to do networking with Swift, i’m looking for a tutorial where you create a Network Layer with swift, what are the best practices etc.

I’ve followed the tutorials on how to create requests, parse data etc. I’m looking for a tutorial on how to integrate that layer into the MVC pattern.

Hi @swiftwitcher,
If you are looking for a solution, then try Alamofire and it works well with Reactive or normal code.

Are you wanting to create your own code and library?

cheers,

Hi thanks for the suggestion, but i would like to create my own framwork, as i like to keep things native as much as possible.

Right now i’m struggling with code duplication. I’m looking for best practices on how i would setup my networking layer.

Should i use protocols that have methods for get/post etc and so on, and implement them differently in each class? What would be the best approach to making your own network layer with as little code duplication as possible?

Oh and should i apply singleton pattern to my url configuration so i use just one throughout the app?

Hi @swiftwitcher,
There is no single “use this only” solution. Good solutions are a combination of things based on what you want to achieve.

Using protocols is a definite plus, so your objects can become network aware, or you can use a different design pattern that lets you manage network but pass an object to serialise and/or parse.

Look at other packages and you will find some things that you might want to implement in your own framework.

cheers,

Jayant

This topic was automatically closed after 166 days. New replies are no longer allowed.