afnetworking-2

setting limit on concurrent tasks in AFNetworking 2 running AFHTTPSessionManager

余生颓废 提交于 2019-11-28 17:58:57
so I know that in the old AFNetworking this was possible using the AFHTTPClient, and I know that if I use AFHTTPRequestOperationManager I can set the queue's limit, but I can't make AFHTTPSessionManager to run only x requests at a time without implementing it by myself using the success block (which I don't want to). The following code did NOT limit my connections: AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.operationQueue.maxConcurrentOperationCount = 1; In line with an interesting discussion here , I have a lot of requests to my server and I choke it until I get

Setting up reachability with AFNetworking 2.0

╄→尐↘猪︶ㄣ 提交于 2019-11-28 17:58:04
I am trying to setup Reachability using the new 2.0 AFNetworking . In my AppDelegate I initialise the sharedManager. // Instantiate Shared Manager [AFNetworkReachabilityManager sharedManager]; Then in the relevant VC method I check to see if isReachable: // Double check with logging if ([[AFNetworkReachabilityManager sharedManager] isReachable]) { NSLog(@"IS REACHABILE"); } else { NSLog(@"NOT REACHABLE"); } At present this is not working as expected in the simulator, but I imagine this would need to be tested on device and not simulator. Question What I would like to do is monitor the

AFNetworking 2.0 and HTTP Basic Authentication

十年热恋 提交于 2019-11-28 15:43:31
Can't find AFHTTPClient on AFNetworking 2.0, to use: AFHTTPClient *client = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://examplewebsite.com]]; [client setAuthorizationHeaderWithUsername:@"username" password:@"password"]; How it needs to be manage on AFNetworking 2.0? Leguman AFNetworking 2.0 new architecture use serializers for creating requests and parsing responses. In order to set the authorization header, you should first initialize a request operation manager that replaces the AFHTTPClient, create a serializer and then call the dedicated method to set the header. For

How to POST data using AFNetworking 2.0?

前提是你 提交于 2019-11-28 12:43:36
I need to send my data by POST, in variable data. I do it like this: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary *params = @{@"email" : email, @"password" : pass }; [manager POST:URLString parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure: ^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; and have: JSON: { Data = "<null>"; Message = "unexpected end of JSON input"; Result = fail; } I know the method - (AFHTTPRequestOperation *

AFHTTPRequestOperationManager post multi-part request not working

被刻印的时光 ゝ 提交于 2019-11-28 10:32:44
问题 Here is the template that I am using from the Git Doc AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary *parameters = @{@"foo": @"bar"}; [manager POST:@"http://example.com/resources.json" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Error: %@", error); }]; Here is how I am using it -(void

AFNetworking - do not cache response

橙三吉。 提交于 2019-11-28 06:55:32
I'm using this code to pull a simple JSON feed from a server: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.responseSerializer = [AFJSONResponseSerializer serializer]; [manager GET:kDataUrl parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"response: %@", responseObject); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"JSON DataError: %@", error); }]; It works. However, after I change the JSON file at kDataUrl , and verify that the change is made in a browser, when I run the app again, I

obj-c AFNetworking 2.0 POST request does not work

北城以北 提交于 2019-11-28 06:35:46
Hi want to send some data (strings and a file) to a server, by using AFNetworking 2.0. Somehow the data for the POST request (for a forumlar) ist not correct, it looks like that the encoding/serialization on the request is missing. As the server can't work with the uploaded data from me. How do I set the encoding/serialization to the request? I assume the URL Form Parameter Encoding, has to be set. The docs states [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:URLString parameters:parameters]; I tried to do that, but I cannot figure out how to do it right. With the

AFNetworking 2.0 queue request when device is offline with setReachabilityStatusChangeBlock does nothing

不想你离开。 提交于 2019-11-28 05:08:21
I've been trying to come up with a solution to queue HTTP requests using AFNetworking when the device is offline, so when it goes back online the requests gets done. As far as I've been able to understand, this is possible setting the setReachabilityStatusChangeBlock: parameter. So far this is what I have: // ViewController.h @interface XYZTicketViewController : UIViewController<NSURLConnectionDelegate> // This is from before I started using AFNetworking, I'm intending to change all the requests to use AFNetworking in the near future. @end // ViewController.m (...) #import

Problems with SSL Pinning and AFNetworking 2.5.0 (NSURLErrorDomain error -1012.)

给你一囗甜甜゛ 提交于 2019-11-28 04:22:08
We’ve been having a hard time securing our app’s network connections with SSL using AFNetworking 2.5.0. We use a self-signed certificate authority and implemented a custom security policy using pinned certificates. We’ve tested quite a few configurations provided by AFNetworking but have not been lucky so far. The error message we receive is: 2015-01-05 19:03:07.191 AppName[9301:319051] Error updating user journey. Error: Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x7ae056b0 {NSErrorFailingURLKey= https://api.XXX.com

AFNetworking 2.0 Send Post Request with URL Parameters

眉间皱痕 提交于 2019-11-28 03:50:43
问题 How do I send a POST request with AFNetworking 2.0 with all the parameters in the URL like such: http://www.myserver.com?api_key=something&lat=2.4&radius=100 Right now I have: NSString* query = @"http://example.com?name=param&date=param"; AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; NSDictionary *parameters = @{}; [manager POST:query parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", responseObject);