afnetworking-2

How to debug and solve a crash in AFNetworking

送分小仙女□ 提交于 2019-12-04 11:23:02
问题 My iOS app uses AFNetworking (2.6.1), and my highest ranking crash is : Crashed: com.apple.NSURLSession-work EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0004000128ab38a0 This is how most stack traces look like in Crashlytics: Thread : Crashed: com.apple.NSURLSession-work 0 libobjc.A.dylib 0x180e29bc8 objc_msgSend + 8 1 CFNetwork 0x181df6518 SessionConnectionLoadable::_loaderClientEvent_DidReceiveConnectionCacheKey(HTTPConnectionCacheKey*) + 56 2 CFNetwork 0x181e75178 __

AFNetworking version 2 content-type error

风格不统一 提交于 2019-12-04 09:55:08
I'm attempting to make an iphone app that will interact with a particular JIRA server. I've got the following code to log in: NSURL *url = [[NSURL alloc] initWithString:@"https://mycompany.atlassian.net/rest/auth/latest/session/"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; NSString *postString = [NSString stringWithFormat:@"{\"username\":\"%@\",\"password\":\"%@\"}", username, password]; [request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]

Chaining background NSURLSession uploads

白昼怎懂夜的黑 提交于 2019-12-04 09:12:11
Has anyone been successful in chaining NSURLSession background uploads? I am trying to upload a huge video file in 5 MB parts using background upload of NSURLSession. The uploads has to be in order. The whole thing works fine in foreground. I am using AFNetwoking for this, and its a multi part upload. But when the app is in background, the first item uploads fine and starts the second one in background (in setDidFinishEventsForBackgroundURLSessionBlock of AFURLSessionManager). But it stops abruptly (my best guess is in 30 seconds, as an app woken up in background has a max lifetime of 30 sec)

Alternative for enqueueHTTPRequestOperation in AFNetworking 2.0

自闭症网瘾萝莉.ら 提交于 2019-12-04 08:09:05
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 setMaxConcurrentOperationCount: value But we are manually starting our download process. I am looking for alternative

NSURLSession, upload task - Get actual bytes transferred

三世轮回 提交于 2019-12-04 07:30:56
I was getting bug reports that my iOS app failed upload of images on slow connections. While my timeout probably wasn't high enough, there was another issue. I found that upload progress quickly went to 100% even though I could see in Charles that bytes were still being transferred. I use the following method of NSURLSession: - (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request fromData:(NSData *)bodyData completionHandler:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler and implement the following delegate method to receive progress

AFNetworking SSL Pinning Expired Certificates

风流意气都作罢 提交于 2019-12-04 03:43:19
How do you update expired ssl certificates if ssl pinning is used on ios apps? It seems like only an app update would enable updating the certificate but then users who don't update the app will not receive this update. The key is to understand the possible values for AFSecurityPolicy 's pinningMode . AFSSLPinningModeCertificate means that the certificate provided by the server must match exactly one of the pinned certificates, which by default are the certificates in your app bundle. This is the mode you are currently using. AFSSLPinningModePublicKey means that the certificate provided by the

how to create simple Http request via AFNetworking

江枫思渺然 提交于 2019-12-04 02:56:33
I am still using ASIHTTPRequest and I am looking forword to move to AFNetworking i also gone through Raywenderlich Crash Course But its not using AFNetworking 2.0 I have just tried below sample which is mentioned at AFNetworking but its not working some how. AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; //manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"]; NSDictionary *parameters = @{@"UserId": @"24",@"ArticleId":@"0"}; NSLog(@"%@",parameters); [manager POST:@"http://mysite.com/api/User/showArticleList" parameters

POST Request with AFNetworking 2.0 not working, but working in HTTP Request tester

十年热恋 提交于 2019-12-03 20:19:27
I've just started using the new AFNetworking 2.0 API having used the previous versions for a while now. I'm trying to do a bog standard http POST request , but sadly I'm not doing too well. This is my current code: AFHTTPRequestOperationManager *operationManager = [AFHTTPRequestOperationManager manager]; NSDictionary *parameters = @{@"username" : self.usernameField.text, @"password" : self.passwordField.text}; [operationManager POST:@"https:URL GOES HERE" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) { NSLog(@"JSON: %@", [responseObject description]); }

(Cocoa error 3840.)" (Invalid value around character 0.) AFNetworking

混江龙づ霸主 提交于 2019-12-03 19:07:16
问题 I've been getting the following error when using the GET method to retrieve a file from a server: Error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Invalid value around character 0.) UserInfo=0x16e81ed0 {NSDebugDescription=Invalid value around character 0.} I've tried a number of different things and I believe it could be something to do with the JSON format on the file that I'm trying to get. Here is the code I've been using:

AFHTTPSessionManager add body to POST

空扰寡人 提交于 2019-12-03 17:07:09
问题 I need too make a post request to my server. With AFHTTPRequestOperation is very simple just use: [request setHTTPBody: [requestBody dataUsingEncoding:NSUTF8StringEncoding]]; However i can't find any example how use the same approach using the AFHTTPSessionManager . Using the method: [self POST:@"extraLink" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { } success:^(NSURLSessionDataTask *task, id responseObject) { } failure:^(NSURLSessionDataTask *task, NSError