afnetworking

AFNetworking Uploading a file

天涯浪子 提交于 2019-12-17 10:46:19
问题 Does any one have a full implementation of uploading a file using AFNetworking. I have found some code on the internet but it is incomplete. The code I have found is here: AFHTTPClient *client= [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://my.client.server.com"]]; NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; [parameters setObject:[fieldName text] forKey:@"field01_nome"]; [parameters setObject:[fieldSurname text] forKey:@"field02_cognome"];

How to set a timeout with AFNetworking

感情迁移 提交于 2019-12-17 07:01:23
问题 My project is using AFNetworking. https://github.com/AFNetworking/AFNetworking How do I dial down the timeout? Atm with no internet connection the fail block isn't triggered for what feels like about 2 mins. Waay to long.... 回答1: Changing the timeout interval is almost certainly not the best solution to the problem you're describing. Instead, it seems like what you actually want is for the HTTP client to handle the network becoming unreachable, no? AFHTTPClient already has a built-in

Volunteermatch API Objective C

时间秒杀一切 提交于 2019-12-17 05:13:10
问题 I am using AFNetworking to perform a web request on the VolunteerMatch API. When I perform the request I receive a 200 code, however I do not receive a response. Here is how a typical VolunteerMatch request looks like: GET /api/call?action=helloWorld&query=... HTTP/1.1 Host: www.volunteermatch.org Accept-Charset: UTF-8 Content-Type: application/json Authorization: WSSE profile="UsernameToken" X-WSSE: UsernameToken Username="acme", PasswordDigest="quR/EWLAV4xLf9Zqyw4pDmfV9OY=", Nonce=

Volunteermatch API Objective C

こ雲淡風輕ζ 提交于 2019-12-17 05:13:08
问题 I am using AFNetworking to perform a web request on the VolunteerMatch API. When I perform the request I receive a 200 code, however I do not receive a response. Here is how a typical VolunteerMatch request looks like: GET /api/call?action=helloWorld&query=... HTTP/1.1 Host: www.volunteermatch.org Accept-Charset: UTF-8 Content-Type: application/json Authorization: WSSE profile="UsernameToken" X-WSSE: UsernameToken Username="acme", PasswordDigest="quR/EWLAV4xLf9Zqyw4pDmfV9OY=", Nonce=

afnetworking 3.0 Migration: how to POST with headers and HTTP Body

与世无争的帅哥 提交于 2019-12-17 03:36:21
问题 I am trying to make a POST request which has HTTPHeader Fields and a HTTP body to the youtube API. Previously in version 2.0 of AFNetworking, I used to do it this way which worked: NSDictionary *parameters = @{@"snippet": @{@"textOriginal":self.commentToPost.text,@"parentId":self.commentReplyingTo.commentId}}; NSString *url = [NSString stringWithFormat:@"https://www.googleapis.com/youtube/v3/comments?part=snippet&access_token=%@",[[LoginSingleton sharedInstance] getaccesstoken]];

AFNetworking error in uploadTaskWithStreamedRequest

半腔热情 提交于 2019-12-14 03:44:39
问题 Error Terminating app due to uncaught exception 'NSGenericException', reason: 'Upload tasks in background sessions must be from a file' when i try NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; configuration for NSURLSession work fine but when i use bellow configuration then application crash and give me error. NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:kBackgroundSessionIdentifier];

How to parse JSON in objective-C iOS

泄露秘密 提交于 2019-12-13 22:17:23
问题 I want to parse JSON in Objective-C in iOS using AFNetworking library { "success": 1, "row": [ { "amount": 2800 } ] } CODE - arrAmount = [responseObject valueForKey:@"row"]; NSLog(@"%@",arrAmount); NSString *strAmount =[NSString stringWithFormat:@"%@", [arrAmount valueForKey:@"amount"]]; self.lblAmount.text =[NSString stringWithFormat:@"%@",strAmount]; 回答1: Response of row contain array not Dictionary, so access amount from first object of Array. NSarray *arrAmount = [responseObject

PATCH to Rails app from iOS Client Returning Status 422

痞子三分冷 提交于 2019-12-13 21:25:11
问题 I have a Rails app with a Business model object with a count of visits . I have an iOS client that interacts with this Rails app using AFNetworking 2.0, and when a user taps a business in the app, it sends a PATCH to the Rails app, incrementing visits for that business. However, I'm getting a status code 422 "Unprocessable Entity" error back from the server, and the business's visits count on the server is not getting incremented. AFHTTPSessionManager - iOS - (NSURLSessionDataTask *

swift afnetworking ssl pinning

◇◆丶佛笑我妖孽 提交于 2019-12-13 19:42:14
问题 var manager: AFHTTPSessionManager init() { manager = AFHTTPSessionManager() manager.requestSerializer = AFJSONRequestSerializer() manager.responseSerializer = AFJSONResponseSerializer() let securityPolicy = AFSecurityPolicy(pinningMode: AFSSLPinningMode.Certificate) let certificatePath = NSBundle.mainBundle().pathForResource("c38acbe05a6328ee", ofType: "crt")! let certificateData = NSData(contentsOfFile: certificatePath)! securityPolicy.pinnedCertificates = [certificateData] securityPolicy

AFNetworking - Check reachability for a domain

元气小坏坏 提交于 2019-12-13 19:27:40
问题 I am using AFNetworking 2.2.1 and trying to use the AFNetworkReachabilityManager to check if a certain domain is reachable, but it always return NO. Maybe I am not using this correctly and would appreciate any pointers. AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager managerForDomain:@"www.google.com"]; // always returns NO: NSLog([manager isReachable] ? @"YES" : @"NO"); I also tried with the startMonitoring method (after the manager variable declaration), but with no