afnetworking

Large Image Caching from Afnetworking

纵然是瞬间 提交于 2019-12-06 00:00:47
I'm using AFNetworking to download some images from the internet to my app. I'm using this code to download those images, AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_linkString[indexPath.item]]]]; requestOperation.responseSerializer = [AFImageResponseSerializer serializer]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)]; _imageView.image = responseObject; } failure

AFNetworking 3.x what is the different between AFHTTPSessionManager and AFURLSessionManager?

半腔热情 提交于 2019-12-05 23:23:30
问题 I'm about to upgrade AFNetworking from 1.x to 3.x. My question is what is the different between AFHTTPSessionManager and AFURLSessionManager ? and when to use each? Which one support both XML and JSON request and response? Thanks 回答1: You generally use AFHTTPSessionManager if you want to do GET or POST requests that might include preparation of JSON or x-www-formurlencoded requests or parsing of complex responses. You can get away with AFURLSessionManager if you're doing very simple requests

Code=-1005 \"The network connection was lost

强颜欢笑 提交于 2019-12-05 21:43:34
am my app made and doing POST request using the AFHTTPRequestOperationManager. I have 4 urls which all works fine with the server, they are pretty much the same format, same usage, etc. So I coded them the same as well.In actually fact I only have an if statement to determine which url I shall use for the same method I made, so every time I request any of the urls with POST I use the same one. For 3 of them they just work perfectly, but the 4th one, no matter how I use it, it always gets me "Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." I tested with this url on my

Can AFNetworking 2 store the cookies

拜拜、爱过 提交于 2019-12-05 20:18:27
I used AFHTTPClient and seems it stored cookies in the box. So when I was logged in. and then reload my app, the cookies were in application automatically. Maybe I confused about this. But seems it works in the way I described. Now I use this code: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager POST:path parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) { }]; But when I restart my application I get message with wrong token when I try request some of my

AFNetworking — get redirect URL

馋奶兔 提交于 2019-12-05 19:27:59
Use a AFNetworking against a REST API. POST to resources/ Server responds with 303 -> see resources/3928.json The the server is giving information here: the id 3928 has been assigned to your resource. Is it possible to learn this URL during the POST operation? Also, I don't really need this resource. Can I avoid actually following the redirect? Another option is to use a 200 with {status:"ok",insert_id:3928} but it feels like this is not necessary -(void)call { NSMutableDictionary *params = [[NSMutableDictionary alloc] init]; [params setObject:YOUR_PARAMETER forKey:KEY]; AFHTTPClient

Why do some dictionary keys have quotes and others don't when printing from debugger?

时光怂恿深爱的人放手 提交于 2019-12-05 18:33:46
So I am currently sending back from my server a JSON object. If I do a print of the responseObject in XCode, I get the following: Printing description of responseObject: { order = 3; "picture_bucket_name" = test; "picture_creation_date" = "2013-01-06T21:49:54.546Z"; "picture_identifier" = 61; "picture_url_with_bucket" = "test/pictures/sop/steps/test_default_320_320.png"; "sub_order" = 0; } Why is the Order key not in " "? This is the only key with a Number that I have to convert from NSString to NSNumber using a NumberFormatter. Why is that? Normally a single word without any spaces and other

AFNetworking. Check download progress for all operation queue

假装没事ソ 提交于 2019-12-05 18:23:23
I have an iOS application made with AFNetworking. I have a singleton custom httpclient subclass and i use it to consume my api and download binary files from server. I need to dowload about 100 files. Is it safe to iterate trough my url array and create one AFHTTPRequestionOperation for each url? My code is this: NSMutableURLRequest* rq = [[MIHTTPClient sharedInstance] requestWithMethod:@"GET" path:@"...." parameters:nil]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:rq] ; operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];

How do I make my AFNetworking “responseObject” that I receive a NSDictionary I can parse?

拥有回忆 提交于 2019-12-05 18:16:22
I have this call with AFNetworking 1.0 that returns a responseObject with the data from the API that I want: [[AFDiffbotClient sharedClient] postPath:@"http://diffbot.com/api/batch" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { However, I have no idea how to process responseObject . If I check [responseObject class] I get NSData . If I NSLog(@"%@", responseObject) I get a bunch of numbers (memory addresses I assume): <5b0a7b22 68656164 65727322 3a5b7b22 6e616d65 223a6e75 6c6c2c22 76616c75 65223a22 48545450 2f312e31 20323030 204f4b22 7d2c7b22 6e616d65

AFNetworking 2.0 - mutable json

别说谁变了你拦得住时间么 提交于 2019-12-05 17:54:21
My code currently looks like this NSURL *URL = [NSURL URLWithString:URLForSend]; NSURLRequest *request = [NSURLRequest requestWithURL:URL]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; operation.responseSerializer = [AFJSONResponseSerializer serializer]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"%@", responseObject); [BoxJsonDataHelper gotNewJson:responseObject]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { NSLog(@"Request Failure Because %@",[error userInfo]);

Pass response from AFHTTPRequestOperation to UIWebview

梦想的初衷 提交于 2019-12-05 16:47:06
My code is making two requests to the server. One into the uiwebview directly and one with the AFHTTPRequestOperation. I'd like to use the AFHTTPRequestOperation and just pass the response into my uiwebview. What is the correct syntax for passing the response into the uiwebview and not loading it again? How do I do that without calling twice from the server? I still want to be able to test the success or failure of the load request and also send username and password to connect to the url. - (BOOL)textFieldShouldReturn:(UITextField *)textField { [itemField resignFirstResponder]; NSUserDefaults