afnetworking-2

AFNetworking code giving me Memory Leaks

梦想与她 提交于 2020-01-05 17:49:19
问题 @implementation GetData static NSString *string = @"https://afternoon-springs-7986.herokuapp.com/"; static NSString *baseStr = @"https://afternoon-springs-7986.herokuapp.com/updateInformation"; -(void) postEventInfo: (NSDictionary *) eventInfoObject { NSURL *url = [NSURL URLWithString:string]; // 6.5% // NSURL *baseURL = [NSURL URLWithString:@"http://localhost:5000/"]; UIWindow *window = [[UIApplication sharedApplication] keyWindow]; UIView *topView = window.rootViewController.view; self

AFNetworking 2.0 API For Multi-part form upload

谁都会走 提交于 2020-01-04 02:16:12
问题 What is the AFNetworking 2.0 method for uploading a multipart form i.e. With AFHTTPSessionManager or AFHTTPRequestOperationManager Here is an example of some AFNetworking < 2.0 code: [[ASAPIClient sharedClient] enqueueHTTPRequestOperation:[[ASAPIClient sharedClient] HTTPRequestOperationWithRequest:[[ASAPIClient sharedClient] multipartFormRequestWithMethod:@"POST" path:@"/some/url" parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { if(_selectedPhoto.image) {

AFNetworking 2.0 API For Multi-part form upload

倾然丶 夕夏残阳落幕 提交于 2020-01-04 02:16:04
问题 What is the AFNetworking 2.0 method for uploading a multipart form i.e. With AFHTTPSessionManager or AFHTTPRequestOperationManager Here is an example of some AFNetworking < 2.0 code: [[ASAPIClient sharedClient] enqueueHTTPRequestOperation:[[ASAPIClient sharedClient] HTTPRequestOperationWithRequest:[[ASAPIClient sharedClient] multipartFormRequestWithMethod:@"POST" path:@"/some/url" parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { if(_selectedPhoto.image) {

Swift Custom Response Serializer is returning images at random

笑着哭i 提交于 2020-01-03 02:51:10
问题 I am currently using Alamofire to Fetch Json data/url-images from a Server. I also created a custom response serializer using this tutorial to convert url images into UIImages upon request. Everything works fine, and I am able to load all of the Images from the server into a UIImageView. The user can then swipe from left to right in order to View each image like a Photo Gallery. The Problem I am having is that my custom response returns the images in a different order. Therefore, every image

setTaskDidReceiveAuthenticationChallengeBlock in AFNetworking 2.0

冷暖自知 提交于 2020-01-02 18:07:32
问题 Anybody know how to handle authentication in the 2.0 version of AFNetworking? I tried the below without success. The block is getting called (I had an NSLog in there) but the response is still a 401 error [self setTaskDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential *__autoreleasing *credential) { *credential = [[NSURLCredential alloc] initWithUser:username

setTaskDidReceiveAuthenticationChallengeBlock in AFNetworking 2.0

百般思念 提交于 2020-01-02 18:07:18
问题 Anybody know how to handle authentication in the 2.0 version of AFNetworking? I tried the below without success. The block is getting called (I had an NSLog in there) but the response is still a 401 error [self setTaskDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential *__autoreleasing *credential) { *credential = [[NSURLCredential alloc] initWithUser:username

What is the recommended way to intercept and prevent redirects with AFNetworking 2.0?

戏子无情 提交于 2020-01-02 10:08:22
问题 It seems to me that the proper place to do this is in AFURLSessionManager , in setting the taskWillPerformHTTPRedirection block, but I am unsure of the best way to handle it. Currently, in my AFHTTPSessionManager subclass, I am setting the redirect block globally for all requests, and I know I can prevent redirects by returning nil here: - (void)setupRedirectBlock { [self setTaskWillPerformHTTPRedirectionBlock:^NSURLRequest *(NSURLSession *session, NSURLSessionTask *task, NSURLResponse

AFNetworking 2.0 - mutable json

孤者浪人 提交于 2020-01-02 05:21:12
问题 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:^

Alternative for enqueueHTTPRequestOperation in AFNetworking 2.0

半腔热情 提交于 2020-01-01 10:28:07
问题 We need to download files concurrently in our application. In earlier version of AFNetworking we have downloaded 2 files concurrently by using the code below: (AFHTTPClient) [_httpClient.operationQueue setMaxConcurrentOperationCount:MAX_CONCURRENT_OPERATIONS]; [self.httpClient enqueueHTTPRequestOperation:downloadObj.downloadOperation]; Now we want to upgrade our AFNetworking to 2.0. Instead of AFHTTPClient we are using AFHTTPRequestOperationManager and able to set

AFHTTPRequestOperationManager return data in block

安稳与你 提交于 2019-12-31 07:15:44
问题 I created an APIController in my application that has several methods that call specific api urls and return a model object populated with the result of the api call. The api works with json and up to now my code looks like the following: //Definition: - (MyModel *)callXYZ; - (MyModel *)callABC; - (MyModel *)call123; //Implementation of one: - (MyModel *)callXYZ { //Build url and call with [NSData dataWithContentsOfURL: url]; //Create model and assign data returned by api return model; } Now