MHNetwork alternatives and similar libraries
Based on the "Networking" category.
Alternatively, view MHNetwork alternatives based on common mentions on social networks and blogs.
-
AFNetworking
A delightful networking framework for iOS, macOS, watchOS, and tvOS. -
CocoaAsyncSocket
Asynchronous socket networking library for Mac and iOS -
RestKit
RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X -
Reachability.swift
Replacement for Apple's Reachability re-written in Swift with closures -
YTKNetwork
YTKNetwork is a high level request util based on AFNetworking. -
ASIHTTPRequest
Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone -
apollo-ios
๐ฑ ย A strongly-typed, caching GraphQL client for iOS, written in Swift. -
swift-protobuf
Plugin and runtime library for using protobuf with Swift -
RealReachability
We need to observe the REAL reachability of network. That's what RealReachability do. -
Netfox
A lightweight, one line setup, iOS / OSX network debugging library! ๐ฆ -
MonkeyKing
MonkeyKing helps you to post messages to Chinese Social Networks. -
SwiftHTTP
Thin wrapper around NSURLSession in swift. Simplifies HTTP requests. -
APIKit
Type-safe networking abstraction layer that associates request type with response type. -
ResponseDetective
Sherlock Holmes of the networking layer. :male_detective: -
Networking
Easy HTTP Networking in Swift a NSURLSession wrapper with image caching support -
XMNetworking
A lightweight but powerful network library with simplified and expressive syntax based on AFNetworking. -
Pitaya
๐ A Swift HTTP / HTTPS networking library just incidentally execute on machines -
Reach
A simple class to check for internet connection availability in Swift. -
Digger
Digger is a lightweight download framework that requires only one line of code to complete the file download task -
SOAPEngine
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app. -
TRON
Lightweight network abstraction layer, written on top of Alamofire -
TWRDownloadManager
A modern download manager based on NSURLSession to deal with asynchronous downloading, management and persistence of multiple files. -
Transporter
A tiny library makes uploading and downloading easier -
Restofire
Restofire is a protocol oriented networking client for Alamofire -
ws โ๏ธ
โ ๏ธ Deprecated - (in favour of Networking) :cloud: Elegantly connect to a JSON api. (Alamofire + Promises + JSON Parsing) -
EVURLCache
a NSURLCache subclass for handling all web requests that use NSURLRequest -
AFNetworking+RetryPolicy
Nice category that adds the ability to set the retry interval, retry count and progressiveness. -
MultiPeer
๐ฑ๐ฒ A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices -
AFNetworking-Synchronous
Synchronous requests for AFNetworking 1.x, 2.x, and 3.x -
ROADFramework
ROAD โ Rapid Objective-C Applications Development
Appwrite - The open-source backend cloud platform
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of MHNetwork or a related project?
README
MHNetwork
Protocol Oriented Network Layer Aim to avoid having bloated singleton NetworkManager
## Philosophy the main philosophy behind MHNetwork is to have a single responsibility. it makes it much easier to determine where is the problem located in your code if every class in your code have only one task and one task only to do. so in the beginning..
install
$ pod install MHNetwork
or in your podfile
pod 'MHNetwork'
also you can use Swift Package Manager
usage
let's say you have movies API .. and you need to make a request call to get the movies list..
you will need to create two files for your feature
MoviesRequests.swift
and MoviesTasks.swift
in the request it should be something like this
import Foundation
import MHNetwork
enum MoviesRequests: Request {
case getMoviesList
var path: String {
return "movies/list/"
}
var method: HTTPMethod {
switch self {
case .getRandomQuote:
return .get
}
}
var parameters: RequestParams {
return .url(["year" : "2018"])
// can use .body(["year": "20018"]) if the api require body parameters
}
var headers: [String : Any]? {
return ["Authorization": "xyz"]
}
}
then add your task
class MovieTasks <T: Codable>: Operations {
var request: Request {
return MoviesRequests.getMoviesList
}
func execute(in dispatcher: Dispatcher, completed: @escaping (Result<T, NetworkError>) -> Void) {
do {
try dispatcher.execute(request: self.request, completion: { (result) in
switch result {
case .success(let response):
switch response {
case .data(let data):
do {
let decoder = JSONDecoder()
// decoder.keyDecodingStrategy = .convertFromSnakeCase
// uncomment this in case you have some json properties in Snake Case and you just want to decode it to camel Case... workes only for swift 4.1 or higher
let object = try decoder.decode(T.self, from: data)
completed(.success(object))
} catch let error {
print("error Parsing with Error: \(error.localizedDescription)")
}
break
case .error(let error):
completed(.failure(error))
break
}
case .failure(let error):
completed(.failure(error))
}
})
} catch {
completed(.failure(.error(code: nil, error: error, data: nil)))
}
}
}
that's it you finished your basic setup for the request.. now you can call it from your code like that
func getMoviesList(onComplete: @escaping (Movie) -> Void, onError: @escaping (Error) -> Void) {
let environment = Environment(host: "https://imdb.com/api")
let networkDispatcher = NetworkDispatcher(environment: environment, session: URLSession(configuration: .default))
let moviesTask = MoviesTasks<Movie>() // Movie Model should be codable
moviesTask.execute(in: networkDispatcher) { (result) in
switch result {
case .success(let users):
onCompletion(movies)
case .failure(let error):
onError(error)
}
})
}
that's it..
one last note.. when creating the instance of MoviesTask you noticed the comment that Movie Model should be Codable
well.. it's not a must but my preferable way.. just suit yourself in the task itself and make it less restricted if you like but you'll need to handle the returned data in another way.
TODO://
- [ ] need to support JSON return type without depending on any 3rd party
- [x] need to fix & clean the example test cases and code
Contribute://
fork / edit / and Pull request to Develop Branch... you know what to do ;)