Questions tagged [nsurlsessiondatatask]

See Apple documentation for Swift (URLSessionDataTask) and Objective C.

249 questions
2
votes
1 answer

Request working properly with postman but fails with protocol error when requesting with iOS

I am trying to run this request and the reason I am doing is that from here is that I want to test push notifications (I mean a lot of them) with different strings in a loop. When I try to do it with Postman it works perfectly fine I mean I had…
user3745635
  • 647
  • 7
  • 19
2
votes
1 answer

iOS UrlSession.shared.dataTask removes utf-8 "+" character and replaces it with " "

I'm creating a login call to an API using x-www-form-endoded data. I created a POST in Postman and received a 200 response. I used Postman's export function to generate the OKHTTP code for Android and NSURL code for iOS. The Android code works…
James Jordan Taylor
  • 1,240
  • 3
  • 17
  • 35
2
votes
0 answers

URLSession dataTask: with URLRequest/URL? OperationQueue in completionHandler?

I want a URLSession to perform an HTTP network call and parse its JSON response. I'm following an example which more or less matches my scenario, and I found this code: let request = URLRequest(url: url) let dataTask = myUrlSession.dataTask(with:…
AppsDev
  • 11,441
  • 20
  • 81
  • 163
2
votes
1 answer

Error with NSURLSessionDataTask in iOS 10

I am having an issue with NSURLSessionDataTask , while trying to upload a JSON object , I am getting the following message in console . [] __tcp_connection_write_eof_block_invoke Write close callback received [error: [89] Operation canceled] How…
2
votes
1 answer

Do not execute the block if task is cancelled

I have MainViewController -> ThumbnailViewController -> ImageFullScreenViewController. As their name implies, I have a main screen from which I go to a screen which shows collection of images and on selecting an image, I open the image in full…
iOS
  • 3,292
  • 2
  • 34
  • 72
2
votes
0 answers

How to Cancel NSURLSessionDataTask 'Inside' A RACSignal

I am using Reactive Cocoa to merge & collect multiple network requests together (as RACSignals) like so: [[[RACSignal merge:requestSignals] collect] subscribeNext:^(NSArray *results){...} Each individual RACSignal is created like so: - (RACSignal…
jac300
  • 4,832
  • 12
  • 49
  • 87
2
votes
1 answer

iOS: AFNetworking multiple download. Request operation timeout

I try to download a large number of files >= 500 with AFNetworking 3.0 GET-request.Total load weight is approximately equal to ~ 1.7 Gb. Currently, I use: for (NSSttring *url in urlsArray){ [self.sessionManager…
2
votes
2 answers

Synchronous fetching data NSOperationQueue or NSURLSession

In my app , we have to make 3 server calls when we click on the login button. 1) will make a server call to get an OAuth token for user credentials 2) with the token from (1) we will get user privileges 3) with the token from (1) and with the valid…
Sharanya K M
  • 1,795
  • 4
  • 22
  • 44
2
votes
0 answers

Using NSURLSessionDataTask, can I resume downloading a file, even if user comes back after quitting an App?

Suppose, I am downloading a file of 300 MB using NSURLSessionDownloadTask or NSURLSessionDataTask (at present, I don’t know which is the best choice in my case). User quits the App or App suddenly crashed while 250 MB were downloaded. When next…
2
votes
0 answers

NSURLSession Show Tasks In Suspended State?

I know that invoking getTasksWithCompletionHandler on an NSURLSession: Asynchronously calls a completion callback with all outstanding data, upload, and download tasks in a session. However, from experimentation, I can see the data, upload, and…
Max MacLeod
  • 24,338
  • 10
  • 91
  • 123
2
votes
1 answer

How to aggregate response from multiple NSURLSessionDataTasks?

I am trying to aggregate the data from multiple NSURLSessionDataTasks that will run concurrently. __block NSMutableDictionary *languageDetails = [NSMutableDictionary new]; [repos enumerateObjectsUsingBlock:^(NSDictionary *repoDict, NSUInteger idx,…
Anish Basu
  • 145
  • 2
  • 5
2
votes
2 answers

NSURLSession delegate didCompleteWithError not called

I have the below implementation of NSURLSession . NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; self.session = [NSURLSession sessionWithConfiguration:configuration …
2
votes
2 answers

Will NSURLRequest timeout value overrides NSURLSessionConfiguration timeoutIntervalForRequest value?

I am creating a NSURLSession object with timeoutIntervalForRequest configuration = 120 seconds. After this I am creating a NSURLSessionDataTask object and calling the method dataTaskWithRequest:completionHandler. Here one input parameter is a…
Advaith
  • 1,047
  • 1
  • 11
  • 30
2
votes
0 answers

Retry an NSURLSessionDataTask request after re-authorizing (AKA NSInvocation equivalent in Swift)

TL;DR version: What is the nearest equivalent to NSInvocation - or similar way to package up a method call, including arguments - in Swift? Background: I have a ServerController object which is used across my app to make requests to an API. The…
Andrew Ebling
  • 9,531
  • 7
  • 51
  • 72
1
vote
1 answer

Asynchronous thread in Swift - How to handle?

I am trying to recover a data set from a URL (after parsing a JSON through the parseJSON function which works correctly - I'm not attaching it in the snippet below). The outcome returns nil - I believe it's because the closure in retrieveData…
MRoot
  • 33
  • 5
1 2
3
16 17