afnetworking

Domain=NSURLErrorDomain Code=-1021 “request body stream exhausted”

北慕城南 提交于 2019-12-12 09:49:40
问题 I am getting the NSURLErrorDomain Code=-1021 "request body stream exhausted" NSLocalizedDescription=request body stream exhausted, NSUnderlyingError=0x2088c080 "request body stream exhausted"} This error is generated when uploading multiple big size images I am using AFNetworking and tried to search for a fix online, but didn't succeed NSDictionary *clientUniqueId = [NSDictionary dictionaryWithObject:NSLocalizedString(uniqueDrId, nil) forKey:@"clientUniqueId"]; NSMutableURLRequest *request =

How to perform a batch of AFNetworking requests that depend on each other

前提是你 提交于 2019-12-12 08:56:10
问题 I need to perform a series of server calls that run sequentially and where one request can only be executed if all previous requests have been successful. So, my idea was to create an AFHTTPRequestOperation for each request and use [myAFHTTPClient enqueueBatchOfHTTPRequestOperations:] to fire them off. I can make them run sequentially by calling [myAFHTTPClient.operationQueue setMaxConcurrentOperationCount:1] But how can I make sure that the remaining operations run only if the previous

Can't use AFHTTPRequestOperationManager

冷暖自知 提交于 2019-12-12 08:23:03
问题 I got a problem when I'm using AFNetworking. I wrote this in my code: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; I do add those files in my project, and I also try pod them into my project like this. But the compiler still told me "use of undeclared identifier 'AFHTTPRequestOperationManager'". Someone can help me? screenshot:screenshot 回答1: In fact, it's because after AFNetworking 3.x, there is no AFHTTPRequestOperationManager any more. You should use

Auto synthesis error in AFURLRequestSerialization with Xcode 6

亡梦爱人 提交于 2019-12-12 08:00:29
问题 How do I fix the warning "auto property synthesis will not synthesize because it is readwrite but it will be synthesized readonly via another property" for the properties streamStatus and streamError that I'm getting with the latest AFNetworking on the Xcode 6 beta? https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFURLRequestSerialization.m#L733 Here's the relavent line in AFURLRequestSerialization.m line 733 and 734: @interface AFMultipartBodyStream () <NSCopying>

Getting continous “The operation couldn’t be completed” after recursive POST call AFNetworking

只谈情不闲聊 提交于 2019-12-12 06:09:43
问题 I am calling POST Json webservice in recursive manner to continuously Upload/download data to service until all is completed. There could be as much as 500-1000 request. But after using for sometime i keep getting below errors. -1012 is most often i get. Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. (NSURLErrorDomain error -1012.)" UserInfo=0x7ae056b0 {NSErrorFailingURLKey=https://api.XXX.com/XXX/XXX/, NSErrorFailingURLStringKey=https://api.XXX.com/XXX/XXX/}

How to form a multipart form data request using AFNetworking 1.3.3

*爱你&永不变心* 提交于 2019-12-12 05:31:16
问题 I am using AFNetworking 1.3.3. I need to make a multipart/form-data request to my server with image data and some other additional stuffs. I have no clue how to format this multipart request. How can I do it? 回答1: On the project's GitHub page (branch 1.x) you can find this example NSURL *url = [NSURL URLWithString:@"http://api-base-url.com"]; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url]; NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"avatar.jpg"],

Download images in order with AFNetworking

試著忘記壹切 提交于 2019-12-12 05:17:50
问题 How do you download images in order with AFNetworking? An by "in order", I also mean executing the success blocks in order. Initially I thought it would be enough to use a NSOperationQueue and set each AFImageRequestOperation as a dependency of the next one. Like this: - (void) downloadImages { { // Reset [_downloadQueue cancelAllOperations]; _downloadQueue = [[NSOperationQueue alloc] init]; _images = [NSMutableArray array]; } AFImageRequestOperation *previousOperation = nil; for (NSInteger i

How to Reload Text Inside UITableCell using AFNetworking

白昼怎懂夜的黑 提交于 2019-12-12 05:15:49
问题 I'm fetching the value of my UILabel from Rotten Tomatoes API and I want my text inside my custom cell to update whenever the value has been fetched already. I tried doing that by reloading my UITableView but it goes on a loop. Here's my code: if (ratingTomatoLabel.text == nil) { NSLog(@" Nil"); NSString *stringWithNoSpaces = [movieTitle.text stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; NSString *rottenTomatoRatingString = [NSString stringWithFormat:@"%@%@%@", @"http://api

AFNetworking Send JSON as a parameter for POST request

我们两清 提交于 2019-12-12 03:46:30
问题 I gone several answers for the same question...but unable to figure out this issue..i am getting this error * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* +[NSJSONSerialization dataWithJSONObject:options:error:]: Invalid top-level type in JSON write' My code is: NSDictionary *loginDict=[[NSDictionary alloc] initWithObjectsAndKeys:password.text,@"password",userName.text,@"userName",nil]; NSError *error; NSData *jsonData = [NSJSONSerialization

How to return a response object using AFJSONRequestOperation

十年热恋 提交于 2019-12-12 03:43:44
问题 I'm trying to get weather data by using AFJSONRequestOperation . The problem is I can't return the object when the query is done. Is there anyone know how to do that? My current implemation is - (NSDictionary *)getCityWeatherData:(NSString*)city { NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://free.worldweatheronline.com/feed/weather.ashx?key=xxxxxxxxxxxxx&num_of_days=3&format=json&q=%@", city]]; NSURLRequest *request = [NSURLRequest requestWithURL:url];