See Apple documentation for Swift (URLSessionDataTask) and Objective C.
Questions tagged [nsurlsessiondatatask]
265 questions
1
vote
2 answers
Call performSegue after URLSession.shared.dataTask
I want to performe a Segue after sending a post request using URLSession.shared.dataTask
ViewController:
@IBAction func Connection(_ sender: AnyObject) {
let loginFunc = Login()
loginFunc.login(username: username.text!, password:…

ZeenaZeek
- 271
- 3
- 5
- 16
1
vote
2 answers
Ios Swift3 : URLSession shared datatask showing an error
I am getting the below error while trying to get data from PHP sever.
URLSession being initialised seems to have an error at shared. Kindly help me to get swift3 equivalent.
This is error message and sample code below :
Ambiguous reference to…

Sujay U N
- 4,974
- 11
- 52
- 88
1
vote
0 answers
How to handle custom delegate inside NSURLSessionDataTask
I am working on a custom request handler which contains NSURLSessionDataTask webservice methods.
After success response I am sending response to ViewController where actual request is triggered, but the thing is whenever I send a web request I am…

kranti
- 93
- 2
- 9
1
vote
2 answers
URL nil after upgrade to swift 3.0
URL is nil after covert to swift 3.0
my swift2 code (This code works prefect)
let correctedAddress:String! = firstResult.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.symbolCharacterSet())
let url = NSURL(string:…

Pak Ho Cheung
- 1,382
- 6
- 22
- 52
1
vote
1 answer
NSURLSession dataTaskWithRequest only works first time
I'm currently developing a WS Call like always, but I don't know why this only works the first time that I call to it, data first time has value, but if I call it again It returns nil. If I look to the response, I can see that it returns me an 412…

Mikel Sanchez
- 2,870
- 1
- 20
- 28
1
vote
2 answers
How to get NSDictionary from NSURLSessionDataTask
-(NSDictionary *)fetchFromUrl:(NSString *)url{
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session…

jane
- 309
- 2
- 11
1
vote
0 answers
AFNetworking 3 and Swift 2- Cannot convert value NSURLSessionDataTask
When trying to access the GET function from AFHTTPSessionManager from , I get error, inputing the operation:
"Cannot convert value of type '(NSURLSessionDataTask!, AnyObject!) -> Void' to expected argument type '((NSURLSessionDataTask, AnyObject?)…

user1704986
- 11
- 2
1
vote
1 answer
Xcode loop array of URLs with NSURLSessionDataTask
I must be making this harder than it is... or implementing the solutions I see online incorrectly.
I have an array of URLs which I would like to loop through and push the results to a dictionary in order or the array. How can I make it wait for the…

Jason Bestor
- 99
- 1
- 2
- 10
1
vote
1 answer
dataTaskWithRequest takes too long for a very specific string
I'm creating an IOS app using swift.
Recently, I've encountered a weird bug.
Im trying to check if a url is valid, therefore, I'm creating a request with the url and check for the response. I do this task with dataTaskWithRequest of…

Eden.F
- 219
- 2
- 6
1
vote
3 answers
NSURLSession, after the data task is converted to download task, it can't download in background
If I run the following code and let the app in background, the download is still continuing. Finally, when the download is finished, I can get the right callback.
let configuration =…

Changwei
- 672
- 1
- 5
- 16
1
vote
1 answer
Swift 2 How do I force Session data task to execute .resume() before continuing
I'm going to crazy trying to figure out how to prevent the rest of my code from executing before a session dataTaskWithRequest is finished. No matter what I do, the data task won't .resume() until everything else finishes. Nothing works. Not using a…

dbconfession
- 1,147
- 2
- 23
- 36
1
vote
1 answer
how to add parameter (for Drupal7 rating field) in http POST request, in swift 2
I am a beginner, trying to code to submit a vote to the Drupal7 ratings field of a node with movie content. Just as the node has a parameter for 'title', there is a parameter for 'rating-percent' which formats = "75%".
A GET request of json output…

Dimitri T
- 921
- 1
- 13
- 27
1
vote
1 answer
NSURLSession crash with JSON data parameter is nil while error is managed
This problem has already been mentioned elsewhere but the solution was dealing with error. And here I think I manage my error correctly (but it sound like I am mistaken...).
I've got something strange I cannot figure out. My app crashes when I…

Trichophyton
- 625
- 5
- 21
1
vote
1 answer
NSData is returning 0 bytes
I am trying to do a simple POST request. However the results seem different in POSTMAN plugin in chrome and in iOS simulator.
Here is the snapshot from POSTMAN:
As you can see, I get the JSON data in retun.
Here is my code to do the POST request:
…

Teja Nandamuri
- 11,045
- 6
- 57
- 109
1
vote
1 answer
Nested dataTaskWithRequest in Swift tvOS
I'm a C# developer convert to Swift tvOs and just starting to learn. I've made some progress, but not sure how to handle nested calls to json. The sources are from different providers so I can't just combine the query.
How do I wait for the…

Brandon
- 25
- 5