[](https://travis-ci.org/Kris Steigerwald/Hunkered)
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.1.0+ is required to build Hunkered
To integrate Hunkered into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Hunkered'
end
Then, run the following command:
$ pod install
import Hunkered
import Alamofire
//Setup your Alamofire Manager
var liveConfig: URLSessionConfiguration {
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 8
configuration.timeoutIntervalForResource = 8
return configuration
}
var trustPolices:ServerTrustPolicyManager = ServerTrustPolicyManager(policies: [ "httpbin.org": .disableEvaluation ])
let liveManager:SessionManager = SessionManager(configuration: liveConfig,
delegate: SessionDelegate(),
serverTrustPolicyManager: trustPolices)
//Stage Hunkered with Live Manager
var requestor:HunkeredRequestManager = HunkeredRequestManager(state: .live, liveManager)
Handling the Response
of a Request
made in Alamofire involves chaining a response handler onto the Request
.
//Set your connection, live or mock mode
requestor?.setState(state: .mock)
requestor?.manager.request("https://httpbin.org/todos").responseJSON { response in
switch response.result {
case .success(let value):
print("It works!", val as Any)
case .failure(let error):
print("Error: Handle failure", error)
}
expect.fulfill()
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ Xcode 8.1, 8.2, 8.3, and 9.0 Swift 3.0, 3.1, 3.2, and 4.0
Hunkered is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Hunkered"
Kris Steigerwald, kris.steigerwald@capitalone.com
Hunkered is available under the MIT license. See the LICENSE file for more info.