Questions tagged [afnetworking]

AFNetworking is a networking library for iOS and macOS available on GitHub and CocoaPods.

AFNetworking is a networking library for iOS and Mac OS X.

At its core is AFHTTPRequestOperation, a thin wrapper around NSURLConnection, which provides a block callback for when the operation completes. Everything else is built on top of that in a way that's completely modular: take what you need, leave what you don't.

Source, examples & more info on github

Documentation

Related

3758 questions
208
votes
14 answers

Request failed: unacceptable content-type: text/html using AFNetworking 2.0

I'm trying out the new version 2.0 of AFNetworking and I'm getting the error above. Any idea why this is happening? Here's my code: NSURL *URL = [NSURL URLWithString:kJSONlink]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; …
jaytrixz
  • 4,059
  • 7
  • 38
  • 57
137
votes
13 answers

NSURLSession/NSURLConnection HTTP load failed on iOS 9

Tried to run my existing app on iOS9 but getting failure while using AFURLSessionManager. __block NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject,…
Tariq
  • 9,861
  • 12
  • 62
  • 103
95
votes
21 answers

Cocoapods + Cannot load underlying module for 'x'

I am running XCode 7, Swift 2.0, iOS 9. I want to install Alamofire in my project using Cocoapods. I have done the following: gem install cocoapods pod setup pod init Updated Podfile to: # Uncomment this line to define a global platform for your…
user5319603
94
votes
6 answers

is there an easy way to get the http status code in the failure block from AFHTTPClient?

I see that there is a list of accepted http status codes that I can modify, but I think it would be cleaner if I can get the http status code in the failure block .. Ok, found the answer with the operation object failure:^(AFHTTPRequestOperation…
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460
93
votes
8 answers

What major ASIHTTPRequest features is AFNetworking missing?

With work having recently stopped on ASIHTTPRequest, it seems like attention is shifting to AFNetworking. However, I've not yet found a good comparison of the features of the two libraries, so I don't know what I might lose if/when I switch…
JosephH
  • 37,173
  • 19
  • 130
  • 154
82
votes
15 answers

AFNetworking Post Request

I'm a newbie in obj-c and have been using asihttp for some of my projects. When doing a post request in asihttp its done this way. ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; [request setPostValue:height…
Sam Barnet
  • 911
  • 2
  • 8
  • 6
80
votes
9 answers

How to set a timeout with AFNetworking

My project is using AFNetworking. https://github.com/AFNetworking/AFNetworking How do I dial down the timeout? Atm with no internet connection the fail block isn't triggered for what feels like about 2 mins. Waay to long....
jennas
  • 2,444
  • 2
  • 25
  • 31
79
votes
7 answers

AFNetworking 2.0 add headers to GET request

I've just started using AFNetworking 2.0 and I was wondering how I put in headers into a HTTP Get request. The documentation sets up a GET like this: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary…
Mackey18
  • 2,322
  • 2
  • 25
  • 39
70
votes
11 answers

how to use Alamofire with custom headers

I am just starting to take a look at Mattt's wonderful new Alamofire swift networking library and am not quite sure how one would use it with custom headers. The code i am trying to convert from AFNetworking to Alamofire is this: let request =…
Reneli
  • 1,756
  • 2
  • 16
  • 26
58
votes
9 answers

List saved files in iOS documents directory in a UITableView?

I have set up the following code to save a file to the documents directory: NSLog(@"Saving File..."); NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.reddexuk.com/logo.png"]]; AFHTTPRequestOperation *operation…
pixelbitlabs
  • 1,934
  • 6
  • 36
  • 65
55
votes
2 answers

How to manage sessions with AFNetworking?

As the title implies, I am using AFNetworking in an iOS project in which the application talks to a server. When the user signs in, the server responds by sending back a success flag and the response headers contain the session ID. I am wondering if…
Bart Jacobs
  • 9,022
  • 7
  • 47
  • 88
54
votes
3 answers

AFNetworking and background transfers

I'm a bit confuse of how to take advantage of the new iOS 7 NSURLSession background transfers features and AFNetworking (versions 2 and 3). I saw the WWDC 705 - What’s New in Foundation Networking session, and they demonstrated background download…
Mario
  • 2,431
  • 6
  • 27
  • 34
50
votes
8 answers

How to download a file and save it to the documents directory with AFNetworking?

I am using the AFNetworking library. I can't figure out how to download a file and save it to the documents directory.
iamsmug
  • 1,517
  • 4
  • 15
  • 25
50
votes
5 answers

Swift Alamofire VS AFNetworking

I am developing an app using Swift. I want to call a REST API. I found there are two popular libraries, AFNetworking and Alamofire. But I don't know which is better (is more popular or has more features). Can anybody suggest what are the main…
Puvanarajan
  • 2,786
  • 6
  • 26
  • 37
49
votes
5 answers

How to batch request with AFNetworking 2?

So I'm rewriting an app for iOS 7 with AFNetworking 2.0 and I'm running into the issue of sending a batch of requests at once and tracking their progress. In the old AFNetworking there was the…
Mac_Cain13
  • 3,611
  • 2
  • 24
  • 38
1
2 3
99 100