afnetworking-2

How to POST data using AFNetworking 2.0?

泪湿孤枕 提交于 2019-11-27 07:23:21
问题 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>";

How to batch request with AFNetworking 2?

不羁岁月 提交于 2019-11-27 05:57:48
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 enqueueBatchOfHTTPRequestOperations:progressBlock:completionBlock: method on AFHTTPClient , this is clearly refactored out and I'm a bit confused on how to enqueue multiple requests. I have created a subclass of AFHTTPSessionManager and I'm using the POST:... and GET:... methods to communicate with the server. But I can't find anything in the code and/or docs to enqueue multiple requests at once like

obj-c AFNetworking 2.0 POST request does not work

非 Y 不嫁゛ 提交于 2019-11-27 05:41:53
问题 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

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

筅森魡賤 提交于 2019-11-27 05:30:33
问题 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

AFNetworking 2.0 AFHTTPSessionManager: how to get status code and response JSON in failure block?

偶尔善良 提交于 2019-11-27 04:11:37
问题 When switched to AFNetworking 2.0 the AFHTTPClient has been replaced by AFHTTPRequestOperationManager / AFHTTPSessionManager (as mentioned in the migration guide). The very first issue I came across when using the AFHTTPSessionManager is how to retrieve the body of the response in the failure block? Here's an example: [self.sessionManager POST:[endpoint absoluteString] parameters:params success:^(NSURLSessionDataTask *task, id responseObject) { // How to get the status code? } failure:^

How to batch request with AFNetworking 2?

♀尐吖头ヾ 提交于 2019-11-27 03:58:31
问题 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 enqueueBatchOfHTTPRequestOperations:progressBlock:completionBlock: method on AFHTTPClient , this is clearly refactored out and I'm a bit confused on how to enqueue multiple requests. I have created a subclass of AFHTTPSessionManager and I'm using the POST:... and GET:... methods to communicate with the

AFNetworking - do not cache response

不想你离开。 提交于 2019-11-27 01:36:45
问题 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

How to get download progress in AFNetworking 2.0?

醉酒当歌 提交于 2019-11-27 00:46:05
I am using AFURLSessionManager to create a new download task: AFURLSessionManager* manager = ... NSProgress* p = nil; NSURLSessionDownloadTask* downloadTask = [manager downloadTaskWithRequest:request progress:&p destination:^NSURL*(NSURL* targetPath, NSURLResponse* response) {...} completionHandler:^(NSURLResponse* response, NSURL* filePath, NSError* error) {...} ]; [downloadTask resume]; The file gets downloaded fine, however, how do I get progress notifications? p is always set to nil. I've filed an issue for that. I've also tried to call setDownloadTaskDidWriteDataBlock on the manager, and

iOS Image upload via AFNetworking 2.0

淺唱寂寞╮ 提交于 2019-11-27 00:45:11
I've been looking examples for the new AFNetworking 2.0 to upload images. But I'm hitting wall and couldn't figure out what's wrong with the code. So this is the code I used NSData *imageData = UIImageJPEGRepresentation(image, 0.5); NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration]; NSURL *URL = [NSURL URLWithString:@"http://myserverurl.com"]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; NSURLSessionUploadTask *uploadTask =

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

爷,独闯天下 提交于 2019-11-27 00:22:29
问题 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