nsurlsession

Transition from RestKit to pure AFNetworking 2.0

北城以北 提交于 2019-12-02 20:24:41
I'd been using RestKit for the last two years, but recently I've started thinking about transition from these monolith framework as it seems to be really overkill. Here's my pros for moving forward: There is big need in using NSURLSession for background fetches and RestKit has only experimental branch for transition to AFNetworking 2.0. No actual dates when transition will be finished. (Main Reason) No need for CoreData support in network library as no need for fully functional offline data storage. Having headache with new concept of response/request descriptors as they don't support

How to get backgroundSession NSURLSessionUploadTask response

[亡魂溺海] 提交于 2019-12-02 19:41:42
I have implemented a NSURLSession that runs in the background (so it can continue the task using the system deamon even when the app is suspended). The issue is that -(void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler is never called. I need to know the response status so I can handle properly the upload failure. According to another post, an Apple engineer told that this delegate method is not called when the session is backgroundSession

NSURLSession dataTaskWithRequest not being called

删除回忆录丶 提交于 2019-12-02 19:33:01
问题 I have a second NSURLSession that is being called directly from the completionHandler of the previous one (it is dependent on the cookies generated from the first call). It worked for a while and sometimes still works, but most of the time does not. When I set through the debugger, it simply goes from the dataTaskWithRequest line to the line past the task.resume() call. Any thoughts? func getDates () -> [NSDate] { var urlDays = NSURL(string: "https://mycorrecturl.com") var requestDays =

NSURLSessionTask never calls back after timeout when using background configuration

末鹿安然 提交于 2019-12-02 19:08:57
I am using NSURLSessionDownloadTask with background sessions to achieve all my REST requests. This way I can use the same code without have to think about my application being in background or in foreground. My back-end has been dead for a while, and I have taken that opportunity to test how does NSURLSession behave with timeouts. To my utter surprise, none of my NSURLSessionTaskDelegate callbacks ever gets called. Whatever timeout I set on the NSURLRequest or on the NSURLSessionConfiguration , I never get any callback from iOS telling me that the request did finish with timeout. That is, when

Set cookies with NSURLSession

為{幸葍}努か 提交于 2019-12-02 18:22:45
Hi I am developing one Iphone application In which I want to set cookies after server response and use that for another request. My network request looks like. NSURLSession *session = [NSURLSession sharedSession]; [[session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response; NSLog(@"sttaus code %i", httpResp.statusCode); if (error) { [self.delegate signinWithError:error]; } else { [self.delegate signinWithJson:data]; } }] resume]; But I don't know how to set cookies. I know I have to use

Set number of concurrent downloads with NSURLSessionDownloadTask

穿精又带淫゛_ 提交于 2019-12-02 18:06:32
I'm using the new NSURLSession API and allowing the user to download files. I'd like to try and tell my NSURLSession how many simultaneous downloads to run, but I don't see a way to do it. I'd like to try to avoid managing the download tasks myself, would be much better if I could tell the system how many to allow instead - that would be better for queuing background downloads as well when my app isn't running. Is there a way to do this? You can set it in the NSURLSessionConfiguration object with the HTTPMaximumConnectionsPerHost property. kaspartus I found a workaround for this timeouts.

NSURLSession with share extension returns -995 on OSX

老子叫甜甜 提交于 2019-12-02 10:25:32
问题 I'm trying to upload data using NSURLSession with a background task from an OSX share extension. As soon as I start the task, by delegate is called back with the world's least helpful error message: The operation couldn’t be completed. (NSURLErrorDomain error -995.) There's no other information in the NSError object, nor in the console. After scouring the internet, the only clue I have is to make sure that I've set up the configuration.sharedContainerIdentifier correctly, however I've already

How to disable the URLCache completely with Alamofire

被刻印的时光 ゝ 提交于 2019-12-02 05:15:05
问题 Using Xcode 7.3 iOS 9.2 all in Swift none of that horrible Objective C I have been working on this for a while and been around the block three times now. I have tried this post here and it didn't work http://www.mzan.com/article/32199494-alamofire-how-remove-cache.shtml I have also try to use apple documentation but that is so crappy I cannot make sense of if. So what I am doing is making two Alamofire calls to my server. One to test the credentials of the login information to see if the

How to disable the URLCache completely with Alamofire

六月ゝ 毕业季﹏ 提交于 2019-12-02 02:02:33
Using Xcode 7.3 iOS 9.2 all in Swift none of that horrible Objective C I have been working on this for a while and been around the block three times now. I have tried this post here and it didn't work http://www.mzan.com/article/32199494-alamofire-how-remove-cache.shtml I have also try to use apple documentation but that is so crappy I cannot make sense of if. So what I am doing is making two Alamofire calls to my server. One to test the credentials of the login information to see if the input is right. The second is to download and return the customer information for there viewing. Both are

Convert NSURLConnection to NSURLSessionUploadTask example

北战南征 提交于 2019-12-02 01:36:01
Hi everyone and thanks in advance for any help providing in understanding in how to convert some NSURLConnection code into the newer NSURLSession. What I am trying to do is to make a POST request to a server, and send a photo base 64 encoded for the key "photo". Below I have an working example written in NSURLConnection and I will like to convert it into NSURLSession. As I read on the apple documentation from what I understood I should use a Data tasks because in my case it is an image and if it is a larger transfer like a video the I should use Upload tasks. Regarding the upload task I have