afnetworking-3

Image upload using AFMultipartFormData AFNetworking 3.0

可紊 提交于 2019-12-08 04:16:17
问题 NSURL *URL = [NSURL URLWithString:@"some APi"]; AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; UIImage *myImageObj = [UIImage imageNamed:@"avatar.jpg"]; NSData *imageData= UIImagePNGRepresentation(myImageObj); [manager POST:URL.absoluteString parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [formData appendPartWithFileData:imageData name:@"file" fileName:@"avatar.jpg" mimeType:@

Sharing session between AFNetworking and UIWebView

隐身守侯 提交于 2019-12-08 02:58:09
问题 Is it possible to share AFNetworking session with UIWebView? I used AFNetworking to login to remote server, but the UIWebView have no idea about the session being created by AFNetworking ? 回答1: Try using the UIWebView+AFNetworking category's to call loadRequest . http://cocoadocs.org/docsets/AFNetworking/3.1.0/Categories/UIWebView+AFNetworking.html 回答2: Actually, AFNetworking and UIWebView share the same cookies storage. So we don't need any special technique to let UIWebView "share" a

iOS AFNetwork 3.0: Is there a faster way to send multiple API requests and wait until all of it is finished?

爱⌒轻易说出口 提交于 2019-12-08 00:23:36
问题 I am currently using the following method to send GET API requests. This method works, but I was wondering if there is a faster way. All I need regarding requirements is to know when all of the Deleted mail has been synced. Any tips or suggestions are appreciated. - (void)syncDeletedMail:(NSArray *)array atIdx:(NSInteger)idx { if (idx < array.count) { NSInteger idNumber = array[idx]; [apiClient deleteMail:idNumber onSuccess:^(id result) { [self syncDeletedMail:array atIdx:(idx + 1)]; }

AFNetworking 3 issue

余生颓废 提交于 2019-12-07 20:27:06
问题 In AFNetworking 3 for invalid SSL certificate I used validatesCertificateChain = false , but now it seems that this field was removed and I can't make requests to my server. Here is class for requests: import UIKit import AFNetworking class ClientHTML: AFHTTPSessionManager { private static var __once: () = { () -> Void in let securityPolicy = AFSecurityPolicy(pinningMode: AFSSLPinningMode.certificate) securityPolicy.validatesDomainName = false securityPolicy.allowInvalidCertificates = true

Image upload using AFMultipartFormData AFNetworking 3.0

放肆的年华 提交于 2019-12-07 17:38:28
NSURL *URL = [NSURL URLWithString:@"some APi"]; AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; UIImage *myImageObj = [UIImage imageNamed:@"avatar.jpg"]; NSData *imageData= UIImagePNGRepresentation(myImageObj); [manager POST:URL.absoluteString parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [formData appendPartWithFileData:imageData name:@"file" fileName:@"avatar.jpg" mimeType:@"image/jpeg"]; // etc. } progress:nil success:^(NSURLSessionDataTask *task, id responseObject) { NSLog(@

AFNetworking 3.0 The data couldn’t be read because it isn’t in the correct format

耗尽温柔 提交于 2019-12-07 05:35:49
问题 There are other questions with similar titles but none of them helped me. I've to send a PUT request to server in order to change the status of appointment so I've made this method -(void)appointmentStatusChangedTo:(NSString *)statusID atAppointmentID:(NSString *)appointmentID In which I'm setting the URL and Parameters as NSString *string = [NSString stringWithFormat:@"%@/API/Appointments/3",BaseURLString]; NSDictionary *para = @{ @"AppointmentStatusId":statusID, @"ID":appointmentID }; Then

How do I download large file with streaming in AFNetworking 3

混江龙づ霸主 提交于 2019-12-06 12:32:06
I want to download large file using AFNetworking 3. But I need to resume download while there is any interruption like internet loss or any other things. If any interrupts while downloading I want to start download from where it stop early. Is it possible using AFNetworking or do I use any other libraries? Please anybody help me. Here is my code. NSURLRequest *request = [NSURLRequest requestWithURL:formattedURL]; //Watch the manager to see how much of the file it's downloaded [manager setDownloadTaskDidWriteDataBlock:^(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t

iOS AFNetwork 3.0: Is there a faster way to send multiple API requests and wait until all of it is finished?

无人久伴 提交于 2019-12-06 04:35:51
I am currently using the following method to send GET API requests. This method works, but I was wondering if there is a faster way. All I need regarding requirements is to know when all of the Deleted mail has been synced. Any tips or suggestions are appreciated. - (void)syncDeletedMail:(NSArray *)array atIdx:(NSInteger)idx { if (idx < array.count) { NSInteger idNumber = array[idx]; [apiClient deleteMail:idNumber onSuccess:^(id result) { [self syncDeletedMail:array atIdx:(idx + 1)]; } onFailure:^(NSError *error){ [self syncDeletedMail:array atIdx:(idx + 1)]; }]; } else { NSLog(@"finished"); }

Sharing session between AFNetworking and UIWebView

孤人 提交于 2019-12-06 04:25:46
Is it possible to share AFNetworking session with UIWebView? I used AFNetworking to login to remote server, but the UIWebView have no idea about the session being created by AFNetworking ? Try using the UIWebView+AFNetworking category's to call loadRequest . http://cocoadocs.org/docsets/AFNetworking/3.1.0/Categories/UIWebView+AFNetworking.html Actually, AFNetworking and UIWebView share the same cookies storage. So we don't need any special technique to let UIWebView "share" a session initialized by AFNetworking , or any native session-based request which uses NSHTTPCookieStorage to store

The data couldn't be read because it isn't in the correct format.\"

寵の児 提交于 2019-12-06 03:51:05
] 2 I am using AFNetworking to send data to server.Below is my code: AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; [manager setRequestSerializer:[AFJSONRequestSerializer serializer]]; [manager setResponseSerializer:[AFJSONResponseSerializer serializer]]; [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; NSMutableDictionary *dict = [[NSMutableDictionary alloc]init]; [dict setValue:[[arrLoginDetails objectAtIndex:0] objectForKey:@"id"] forKey:@"user_id"]; [dict setValue:[[arrLoginDetails objectAtIndex:0] objectForKey: