afhttprequestoperation

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

Swift error Cannot convert value of type '(AFHTTPRequestOperation?, AnyObject?) -> ()

廉价感情. 提交于 2019-12-24 05:52:33
问题 After I update xcode Version 8.0 (8A218a) swift 3, I got this error Cannot convert value of type '(AFHTTPRequestOperation?, AnyObject?) -> ()' to expected argument type '((AFHTTPRequestOperation?, Any?) -> Void)!' This is the following code that's shown error above. jsonmanager.post( "http://myapi.com", parameters: nil, success: { (operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in if(responseObject.object(forKey: "meta")?.object(forKey: "status")?.intValue == 200){.... Am i

Swift error Cannot convert value of type '(AFHTTPRequestOperation?, AnyObject?) -> ()

我的梦境 提交于 2019-12-24 05:52:21
问题 After I update xcode Version 8.0 (8A218a) swift 3, I got this error Cannot convert value of type '(AFHTTPRequestOperation?, AnyObject?) -> ()' to expected argument type '((AFHTTPRequestOperation?, Any?) -> Void)!' This is the following code that's shown error above. jsonmanager.post( "http://myapi.com", parameters: nil, success: { (operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in if(responseObject.object(forKey: "meta")?.object(forKey: "status")?.intValue == 200){.... Am i

Timeout POSTING to S3 from iOS using signed URLS

风格不统一 提交于 2019-12-23 12:41:05
问题 My server is generating info for a signed upload to S3. When I pass that info on to iOS, it works for small files. Sometimes it works for bigger ones as well, but it often times out. I am currently testing on iOS 7 over WIFI. It's typical for it to time out after about 60% on an approximately 35 MB file, but sometimes it completes and sometimes it times out sooner. My server generates the following info, which I pass on as form parts to my POST. (I also tried it as parameters with similar

NSOperationQueue: a sequence of NSOperation's with dependencies VS (maxConcurrentOperationCount == 1)?

蓝咒 提交于 2019-12-23 02:46:26
问题 For example I have 3 objects: NSOperation *op1 = ...; NSOperation *op2 = ...; NSOperation *op3 = ...; [op3 addDependency:op2]; [op2 addDependency:op1]; NSOperationQueue *queue = ...; queue.maxConcurrentOperationCount = 1; [queue addOperations:@[op1, op2, op3] waitUntilFinished:NO]; I could simply add all the operations in correct order. But for example if op2 is cancelled then I should also cancel op3 and I can't fully clear a queue in this case. My questions: 1)Is it safe to combine such

Queue of AFHTTPRequestOperations creating Memory Buildup

别等时光非礼了梦想. 提交于 2019-12-08 02:44:24
问题 I just updated to AFNetworking 2.0 and I am re-writing my code to download data & insert it into Core Data. I download JSON data files (anywhere from 10-200mb files), write them to disk, then pass them off to background threads to process the data. Below is the code that downloads the JSON & write it to disk. If I just let this run (without even processing the data), the app uses up memory until it is killed. I assume as the data is coming in, it is being stored in memory, but once I save to

AFNetworking error 53 during attempted background fetch

◇◆丶佛笑我妖孽 提交于 2019-12-07 02:59:24
问题 While updating my application to support Background App Refresh I ran into problem with AFNetworking. I am getting NSPOSIXErrorDomain Code=53 "Software caused connection abort" . The problem seems to occur in iOS 12, where the background connection gets terminated. AFNetworking 2.6.3 is used to make the fetch. AppDelegate.m : - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [OrdersService performFetch];

Queue of AFHTTPRequestOperations creating Memory Buildup

[亡魂溺海] 提交于 2019-12-06 10:56:42
I just updated to AFNetworking 2.0 and I am re-writing my code to download data & insert it into Core Data. I download JSON data files (anywhere from 10-200mb files), write them to disk, then pass them off to background threads to process the data. Below is the code that downloads the JSON & write it to disk. If I just let this run (without even processing the data), the app uses up memory until it is killed. I assume as the data is coming in, it is being stored in memory, but once I save to disk why would it stay in memory? Shouldn't the autorelease pool take care of this? I also set the

AFNetworking error 53 during attempted background fetch

孤街浪徒 提交于 2019-12-05 06:36:05
While updating my application to support Background App Refresh I ran into problem with AFNetworking. I am getting NSPOSIXErrorDomain Code=53 "Software caused connection abort" . The problem seems to occur in iOS 12, where the background connection gets terminated. AFNetworking 2.6.3 is used to make the fetch. AppDelegate.m : - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { [OrdersService performFetch]; completionHandler(UIBackgroundFetchResultNewData); } OrdersService.m : -(void) performFetch { [

AFHTTPRequestOperationManager return data in block

你。 提交于 2019-12-02 10:18:06
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 I want to use the great AFNetworking framework to get rid of that "dataWithContentsOfURL" calls. So I