PocketNet 2.4.1

PocketNet 2.4.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2021
SPMSupports SPM

Maintained by Jose Antonio García Yáñez.



PocketNet 2.4.1

  • By
  • PocketSwift

PocketNet

CocoaPods Compatible License

PocketNet

Elegant net abstraction layer written in Swift 5.0, we provide an integration with Alamofire.

Requirements

  • iOS 8.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1+ is required to build PocketNet 2.4.0

To integrate PocketNet into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'PocketNet'
end

Then, run the following command:

$ pod install

Usage

import PocketNet

let net: PocketNet = PocketNetAlamofire() /*or for SSL Pinning*/ PocketNetAlamofire(pinningSSLCertURL: Bundle.main.url(forResource: "cert", withExtension: "crt"), domain: "urlDomain")
    
let netSupport = NetSupport(net: net)

let request = NetRequest.Builder()
            	.method(.post)
                .url("url")
                .requestHeader([:])
                .parameterEncoding(.json)
                .body(params: "")
                .shouldCache(false)
                .build()

netSupport.netJsonMappableRequest(request, completion: {(result: Result<DecodableObject, Error>) in
	switch result {
	case .success(let decodableObject):
		/// do something with decodableObject
	case .failure(let error):
	    /// do something with error
	}
})

netSupport.netArrayJsonMappableRequest(request, completion: {(result: Result<[DecodableObject], Error>) in
    switch result {
    case .success(let decodableObject):
        /// do something with decodableObject
    case .failure(let error):
        /// do something with error
    }
})

Authors

Special thanks

Libraries used in this project

License

Net is available under the MIT license. See the LICENSE file for more info.