mbrucedogs / Alamofire-Synchronous

Synchronous requests for Alamofire

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alamofire-Synchronous

Synchronous requests for Alamofire

Requirements

  • iOS 8.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+

  • Xcode 7.1+

Installation

pod 'Alamofire-Synchronous', :git => 'https://github.com/zhuangluda/Alamofire-Synchronous.git'

Usage

//json
let response = Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"]).responseJSON()
if let json = response.result.value {
	print(json)
}

//download with progress
let response = Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination).progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
	print(bytesRead)
	// This closure is NOT called on the main queue for performance
	// reasons. To update your ui, dispatch to the main queue.
	dispatch_async(dispatch_get_main_queue()) {
		print("Total bytes read on main queue: \(totalBytesRead)")
	}
}.response()
if let error = response.error {
	print("Failed with error: \(error)")
} else {
	print("Downloaded file successfully")
}

//or without
let response = Alamofire.download(.GET, "https://httpbin.org/stream/100", destination: destination).response()
if let error = response.error {
	print("Failed with error: \(error)")
} else {
	print("Downloaded file successfully")
}

License

See LICENSE for details.

About

Synchronous requests for Alamofire

License:MIT License


Languages

Language:Swift 81.3%Language:Ruby 18.7%