- OS: iOS 10+
- Languages: Written in Swift, supports apps in both Swift and Objective-C
A template framework that handles network requests in a generic way. Why? The idea is to remove your project dependencies on a single networking library. This project should allow the switching of network libraries, currently it support Siesta, but should be able to support many other libraries and keep the same interface.
This library is also a good example on how to move your common code into a seperate library, this way you can share this with many projects, maybe you decide to make a seperate iPad project? maybe just another project that uses the same api's, this way you can keep the logic in one place and share it.
Add to your current project pod file,
pod 'SwiftTemplateFramework', :git => 'https://github.com/Reedyuk/SwiftTemplateFramework.git'
Initialise the network layer in your appDelegate method 'didFinishLaunchingWithOptions'
Urls.changeLocalConfig(newLocalConfig: [.all: "https://google.com"]) NetworkRequestAdapter.sharedInstance.createNewInstancesOfServices(networkRequestAdapterDelegate: nil)
Then simply make a 'service' class which deals with the endpoint, e.g. userService, then you can make simple requests with one line calls:
NetworkRequestAdapter.performRequest(path: "/questions", onSuccess: onSuccess, onFailure: onFailure)
This repo includes a simple network example project. To download the example project, install its dependencies, and run it locally.
pod install
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Andrew Reed - [email protected]
- Create example project using the framework.