Questions tagged [alamofire]

Alamofire is an HTTP networking library written in Swift.

Alamofire is an HTTP networking library written in Swift.

Features

  • Chainable Request / Response Methods
  • URL / JSON / plist Parameter Encoding
  • Upload File / Data / Stream / MultipartFormData
  • Download File using Request or Resume Data
  • Authentication with URLCredential
  • HTTP Response Validation
  • Upload and Download Progress Closures with Progress
  • cURL Command Output
  • Dynamically Adapt and Retry Requests
  • TLS Certificate and Public Key Pinning
  • Network Reachability
  • Comprehensive Unit and Integration Test Coverage

Project

6065 questions
12
votes
6 answers

How to clear AlamofireImage setImageWithURL cache

I am using AlamofireImage in my project quite a lot and I use let URL = NSURL(string: "https://cdn.domain.com/profile/image.jpg")! imageView.af_setImageWithURL(URL) to fetch an image from my CDN. I have done some tests but correct me if I am wrong,…
puks1978
  • 3,667
  • 11
  • 44
  • 103
12
votes
1 answer

Checking for multiple asynchronous responses from Alamofire and Swift

I am writing an application that depends on data from various sites/service, and involves performing calculations based on data from these different sources to produce an end product. I have written an example class with two functions below that…
jonhurlock
  • 1,798
  • 1
  • 18
  • 28
12
votes
4 answers

Setting Custom HTTP Headers in Alamofire in iOS 7 not working

I've tried to set the Alamofire.Manager.sharedInstance.session.configuration.HTTPAdditionalHeaders with my custom HTTP Headers in iOS 7 but I have had no luck. This works fine in iOS 8. Does anyone have any suggestions?
user2362696
  • 141
  • 1
  • 7
11
votes
3 answers

Alamofire 5 upload encodingCompletion

I'm working with Swift 4 and Alamofire 5, I upload two multibart photos and I want to print the progress AF.upload( multipartFormData: { MultipartFormData in MultipartFormData.append(firstPic, withName: "first_pic", fileName:…
Sophie Bernard
  • 197
  • 3
  • 13
11
votes
1 answer

Understanding AlamoFire OAuth Example

I was able to get a working implementation of OAuth example as provided by AlamoFire. However, I am looking to understand certain lines of code and how it works. Full Example: class OAuth2Handler: RequestAdapter, RequestRetrier { private…
Alan
  • 9,331
  • 14
  • 52
  • 97
11
votes
2 answers

Using Google Places API with Alamofire 4.0 and iOS 10 and Swift 3

My project is currently built in Xcode 8 and in Swift 3 with Alamofire 4.0. I use CocoaPods to implement Alamofire. My podfile is as follows: # Uncomment the next line to define a global platform for your project platform :ios,…
Matt Wyeth
  • 1,124
  • 2
  • 10
  • 19
11
votes
1 answer

Alamofire 4 URL Request parameter encoding to JSON

Recently upgraded to Alamofire 4 and running into few issues. Wondering how to encode the url request parameter to JSON in Alamofire Router. Here is the example I was following in Alamofire 3. enum UserRouter: URLRequestConvertible { static let…
user2498258
  • 153
  • 2
  • 3
  • 11
11
votes
3 answers

Parsing JSON using the new Swift 3 and Alamofire

I'm using Alamofire as HTTP library, since the update to Swift 3, how do you parse JSON based on the example below? Alamofire.request("https://httpbin.org/get").responseJSON { response in debugPrint(response) if let json =…
Lawrence Gimenez
  • 2,662
  • 4
  • 34
  • 52
11
votes
4 answers

swift, alamofire cancel previous request

I have an NetworkRequest class, where all my alamofire requests made: class NetworkRequest { static let request = NetworkRequest() var currentRequest: Alamofire.Request? let dataManager = DataManager() let…
Ruslan Sabirov
  • 440
  • 1
  • 4
  • 19
11
votes
2 answers

Code=-1001 "The request timed out."

I am working on a Swift project which requires a lot of consumption of APIs. Everything is working fine but sometimes (1 in 20), I get Code=-1001 "The request timed out." error while calling the API. I am using Alamofire. I am attaching the code…
Rahul Garg
  • 153
  • 1
  • 1
  • 12
11
votes
4 answers

how to pass a nil value for one of the parameter in alamofire Post request

I would like to pass a nil value i.e., optional to one of the parameter value. And it must proceed with the nil value in the Alamofire Post request .It would be helpful if you tell me how to proceed next? let image: UIImage = UIImage() let…
Praveen Kumar
  • 298
  • 2
  • 15
11
votes
1 answer

Alamofire: How to Handle 401 Globally?

I am trying to build a class which manages my network calls for my project. To this time, I mean handling errors globally, everything was fine. I created two functions; for post requests postRequest(:_) and for get requests getRequests(:_).…
Faruk
  • 2,269
  • 31
  • 42
11
votes
2 answers

RxSwift, how do I chain different observables

I am still a beginner in Reactive programming, and RxSwift in general. I want to chain two different operation. In my case I simply want to download a zip file from a web server, and then unzip it locally. I also want, at the same time to show the…
Punty
  • 910
  • 2
  • 11
  • 18
11
votes
3 answers

Cancel all web service calls from Alamofire

In my project there are 4 web services running in the background. I would like to stop all these services on logout from the current state without waiting for response. I have found this code for doing…
Janak Thakkar
  • 414
  • 5
  • 20
11
votes
2 answers

AlamofireImage af_setImageWithURL in a UITableViewCell without placeholder image

I'm using AlamofireImage to set an image on a UIImageView in a UITableViewCell like so: cell.imageView.af_setImageWithURL(url) The image doesn't show after downloading. It will show the image the second time when it's loaded from the memory cache.…
Jorn van Dijk
  • 1,973
  • 1
  • 15
  • 23