See Apple documentation for Swift (URLSessionDataTask) and Objective C.
Questions tagged [nsurlsessiondatatask]
265 questions
0
votes
0 answers
Why isn't the dataTask's completion handler being called?
I have this nagging problem that I just can't seem to fix. I'm trying to call a function within a particular class (called BMUserManagementService), but for some reason the completion handler in the data task is not executing. The method is below…

JFortYork
- 137
- 10
0
votes
1 answer
URLSession omits delegate's redirection management method
I am sending a DataTask to some website and in URL I have redirection to localhost (https://...&redirect_uri=http://localhost...). Overall in that call I am getting about 5 redirections, where localhost is probably third and after that redirection…

Oschły
- 53
- 1
- 7
0
votes
0 answers
URLSession's dataTaskPublisher ends with a 'Cancelled' response vs regular completion. Why?
Environment:
Xcode Version 11.3 (11C29)
Apple Swift version 5.1.3
Scenario:
Combine Neophyte attempting to learn URLSession.shared.dataTaskPublisher
Details:
I made a simple app to access weather data (any data) via two means:
1) Standard and…

Frederick C. Lee
- 9,019
- 17
- 64
- 105
0
votes
0 answers
swift memory growing indefinitly in URLSession URLSessionDataTask
I'm running requests in a loop and see that the memory usage is growing unbounded
I think that the URLSessionDataTask objects aren't released by the URLSession
My code looks like this
let base = "http://myserver.com"
let group = DispatchGroup()
//…

Avba
- 14,822
- 20
- 92
- 192
0
votes
1 answer
URLSession.shared.dataTask freezes the UI
I am making a Swift app for iOS and I have an issue on a request I make.
This request is made every 3 to 5 seconds and the body is a 5k lines JSON (~130k characters in total) that refreshes a UITableView. The issue is that every time .dataTask is…

Anthony
- 804
- 3
- 12
- 32
0
votes
1 answer
iOS Crash saying : [NSURLSessionDataTask state]: unrecognised selector sent to instance
I have screen with searchbar, when i leave this screen, i am just cancelling the ongoing running urlSessionDataTask. Here, is my code, by which i am using:
override func viewWillDisappear(_ animated: Bool) {
if self.lastURLSessionDataTask !=…

Mehul Thakkar
- 12,440
- 10
- 52
- 81
0
votes
1 answer
Swift Get URLSessionDataTask start time / current operation time
I have a URLSessionDataTask instance and I would like to know when the operation started (a Date object) so I can calculate how much time has elapsed.
I've found URLSessionTaskTransactionMetrics in Apple's documentation…

Evan Kaminsky
- 695
- 10
- 23
0
votes
1 answer
Testing NSURLSession "resume cannot be sent to abstract instance of class NSURLSessionDataTask"
I want to test NSURLSession but I get the error "resume cannot be sent to abstract instance of class NSURLSessionDataTask".
Example code is in https://github.com/stevencurtis/abstract-instanceofclassNSURLSessionDataTask
My HTTP Manager works…

stevenpcurtis
- 1,907
- 3
- 21
- 47
0
votes
1 answer
Does URLSession.dataTask(with:completionHandler:) always call completionHandler only once?
After I create a new session data task with URLSession.dataTask(with:completionHandler:) and start the task by calling its resume() method, given that the app doesn't crash while the request is running, is it safe for me to assume that…

ma11hew28
- 121,420
- 116
- 450
- 651
0
votes
1 answer
Multiple URLSession dataTask on asynchronous call with completion handler causes memory goes up
I'm developing an upload project in swift. I'm taking very large files (video, picture with size over 500 MB) with imagepickercontroller and dividing this file into chunks which has a size 1 MB. Then I send these chunks to remote server and make…

ensar.koseoglu
- 5
- 5
0
votes
1 answer
NSURLCaching with dataTask fails to read Cache back with NSURLRequest when offline
I am very confused by iOS caching system. It should be straightforward but it not (for me). I am writing an database App which allows for external web access to a limited range of additional reference material in the form of web pages. Sometimes a…

BlueskyMed
- 765
- 7
- 24
0
votes
0 answers
URLSession.shared.dataTask return zero bytes
My goal is to call a http service that returns a json to be parsed as an array of NewsModel objects.
I defined a struct like that
struct NewsModel: Decodable {
var id: Int
var title: String
var content: String
}
and wrote this method…

cicaletto79
- 179
- 1
- 12
0
votes
4 answers
URLSession.dataTask return the data with 0
I have a web page for giving me the server data in JSON format and I am trying to to reach the site and get these objects. But the data will return with 0; empty variable. My code like this.
func downloadItems() {
let url: URL = URL(string:…

Mertalp Tasdelen
- 171
- 14
0
votes
1 answer
Handling large number of API requests in iOS App (Not using Alamofire)
How to handle the states in which the app goes into foreground setting off a number of requests (around 3-4 minimum) because that information is required in the app, and then going to background?
What I have tried is to use a RequestManager to…

esh
- 2,842
- 5
- 23
- 39
0
votes
1 answer
How to receive uploaded file in PHP? File is uploaded by iOS app written in Swift
Here is my swift code that uploads the file from application.
final class UploadService {
// I'm renting a remote server and the php code is on that
private let videoUploadPath = "http://myUploadPath.php"
var uploadsSession: URLSession!
…

David Wu
- 105
- 2
- 13