afnetworking-2

AFNetworking 2.0 track file upload progress

…衆ロ難τιáo~ 提交于 2019-11-28 03:29:27
I am relatively new to AFNetworking 2.0. Using the code snippet below, I've been able to successfully upload a photo to my url. I would like to track the incremental upload progress, but I cannot find an example of doing this with version 2.0. My application is iOS 7, so I've opted for AFHTTPSessionManager. Can anyone offer an example of how to modify this snippet to track upload progress? AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"myimage.jpg"], 1.0); [manager POST:@"http://myurl.com" parameters

AFNetworking 2.0 add headers to GET request

馋奶兔 提交于 2019-11-28 03:11:18
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 *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); }]; But since we're not handling NSURLRequests I'm not

Swift and AFNetworking integration [closed]

时光毁灭记忆、已成空白 提交于 2019-11-28 02:30:57
问题 Now as swift is the new language to develop iOS apps. How can we integrate with the AFNetworking or using NSURLSession will be a better option ??? Please help me out.. 回答1: You have to add AFNetworking to your swift project In Build Settings -> Defines Module set to Yes In Build Settings -> Swift compiler -> Objective-C bridging file set the name of bridging file 'ProjectName-Bridging-Header.h' for example In ProjectName-Bridging-Header.h write: #import "AFNetworking.h" 回答2: Any Objective-C

convert NSTaggedPointerString to NSString

*爱你&永不变心* 提交于 2019-11-28 02:29:23
问题 I had called an interface of Baidu to check id Number, however the value of Sex returned with sex = M , without "" around the M in JSON, when I use NSString in module to store it and then print the class name of this sex property, it printed as NSTaggedPointerString , I doubt how to convert it to a String to use it. Anyone have good ideas? 回答1: NSTaggedPointerString is already an NSString , it's just a subclass. You can use it anywhere you can use an NSString , without conversion. 回答2: I have

Passing parameter in url for GET method using afnetworking

依然范特西╮ 提交于 2019-11-28 01:38:49
问题 i have url in which query is executed. https://<BASE_URL>/<TENANT_URL>/?query=where UserName='abc'&companyId=&page=1&pageSize=25&filterResultByColumns=true i am escaping the remaining part after tenant url like this, NSString *requestUrl = [[NSString stringWithFormat:@"%@/?query=where UserName='%@'&companyId=&page=1&pageSize=25&filterResultByColumns=true",<TENANT_URL>,userCredential.userName]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; requestUrl = [NSString

AFNetworking 2.0 and HTTP Basic Authentication

旧时模样 提交于 2019-11-27 19:51:12
问题 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? 回答1: 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

How to download image with AFNetworking 2.0?

痴心易碎 提交于 2019-11-27 17:30:09
Appareantly there is no AFImageRequestOperation , but only AFImageResponseSerializer and frankly I don't get it or maybe I'm just looking too long through AFNetworking site... Downloading images with previous AFNetworking was like a charm. I'd hate to go back to older AFnetworking, since I did almost all stuff via the new version... Anyone? SO you want something like this for 2.0. AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; requestOperation.responseSerializer = [AFImageResponseSerializer serializer]; [requestOperation

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

旧街凉风 提交于 2019-11-27 17:20:00
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:^(NSURLSessionDataTask *task, NSError *error) { // How to get the status code? response? }]; In the success

Setting up reachability with AFNetworking 2.0

℡╲_俬逩灬. 提交于 2019-11-27 10:56:49
问题 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

What is “error in __connection_block_invoke_2: Connection interrupted” in iOS?

自古美人都是妖i 提交于 2019-11-27 08:42:39
I am tried to make iOS Application using AFNetworking in UITableView . TableView loads 20 datas like Twitter's timeline. When it loads over 80 datas, Xcode shows spending about 70MB memory and console shows "Received memory warning." And **"error in __connection_block_invoke_2: Connection interrupted".** What is this and How do I treat this error? Rajesh Loganathan Reason: When you load more data which contains above 70 mb will get crash. Sol: Load data (EG:)40 only at a time. Then load another (EG:)40 next time by fetching data from web service. Fetch (EG)40 data by hitting service each time