See Apple documentation for Swift (URLSessionDataTask) and Objective C.
Questions tagged [nsurlsessiondatatask]
265 questions
0
votes
3 answers
Cannot invoke 'dataTask' with an argument list of type (with: NSMutableRequest, ...)
func performGetRequest(_ targetURL: URL!, completion: @escaping (_ data: Data?, _ HTTPStatusCode: Int, _ error: NSError?) -> Void) {
let request = NSMutableURLRequest(url: targetURL)
request.httpMethod = "GET"
let sessionConfiguration…

Krutika Sonawala
- 1,065
- 1
- 12
- 30
0
votes
1 answer
session.dataTask synchronization issue
I have some trouble with the code below.
Though it works, there is some timing problem.
First let me say what I expect, I suppose the completion handler should be run when the data download is complete and my image ready to use. But reality seems to…

Michel
- 10,303
- 17
- 82
- 179
0
votes
1 answer
NSURLSession how to retrieve only titles?
Here is an example of my code:
- (void)displayURL {
NSString *myUrlString = @"https://3docean.net/search/apple%20watch?page=1";
NSURL *myUrl = [NSURL URLWithString:myUrlString];
NSURLSession *session = [NSURLSession…

Dr_Mom
- 63
- 8
0
votes
0 answers
nsurlsession post to php file is not executing completionHandler
I am trying to make a connection to post and set values to my php file locally located however when I execute this code it doesn't execute my completionHandler. am I doing something wrong in the request?? how can i check if the php is getting that…

Mauricio Solís
- 1
- 1
0
votes
0 answers
Background Transfer/ Download in IOS When app need to call sequential API more then 1 hour
I need to call 180 sequential serial GET request (After completion on one request will fire another request) and response time is 32 sec for each request, when App is in background mode and user locked iPhone. 180 * 32 = 5760 seconds == 96 min.
I…

Anurag Dixit
- 119
- 2
- 16
0
votes
1 answer
Invoke URLSession.shared.dataTask when the app is background
I am try to post data back to server when the app is in background or suspended state. I have implemented actionable push notification with yes and No actions. I have to update the backend with the yes or no is tapped.
My below code works fine if…

Warrior
- 39,156
- 44
- 139
- 214
0
votes
0 answers
How to make nsurldatatask completion handler to run initially?
I am using nsurldatatask and getting some data through it and populate that data in tableview. However, i am unable to get data for the first time rather Iam getting it for second time and initial output is getting as null in my tableview. How to…

Akash IOS
- 1
- 6
0
votes
1 answer
Unable to get data out of datatask completion handler in objective c
I am trying to get data through JSON approach using nsurlsessiondatatask but I am unable to get the data out of the data task completion handler.
Please help????

Akash IOS
- 1
- 6
0
votes
1 answer
IOS Swift how can I return label response faster
I am using a rest API for logging in I simply send a request with the user's email and password . If they match in the database then I return some Json and swift parses it . That part is working correctly what I am trying to do now is figure out how…

Rome Torres
- 1,061
- 2
- 13
- 27
0
votes
1 answer
Swift: How to deinitialize a URLSession when other URLSession is initialized?
I have a URLSessionDataDelegate to upload a picture to a server and the following is one part of it.
The URLSession is initialized immediately when I select an image to be uploaded.
But if the user taps on the Upload button and if there is no…

Ananth
- 31
- 1
- 4
0
votes
1 answer
NSURLSessionDataTask on different thread destroys session cookies from UIWebView
I have a quite ugly problem with a subclassed UIWebView which is maintaining a user's web session with an online backend server, that will communicate with a session object, while the user is logged in to a specific service. From time to time, my…

konran
- 588
- 7
- 20
0
votes
0 answers
Why is NSURLSession:delegate: significantly slower than NSURLSession:completionHandler:?
I noticed that my application is connecting to remote resources way slower than web browsers, or cURL and decided to do some digging.
I've been using NSURLSession sessionWithConfiguration:delegate: to handle server responses, and decided to try…

j b
- 5,147
- 5
- 41
- 60
0
votes
1 answer
NSURLSession data task response handling
I am currently working on implementing a networking model that communicates with a REST API through HTTP in Swift using NSURLSession class.
For preparing the request, I use this code:
var request = URLRequest(url: requestURL) // url is…

user3581248
- 964
- 10
- 22
0
votes
0 answers
pull json array from php page with swift
I have a php page that returns a JSON array, here is the php:
$sql ="SELECT * FROM SongTable";
if ($result = mysqli_query($con, $sql)) {
while ($row = mysqli_fetch_row($result)) {
$allarray[] = $row;
}
echo json_encode($allarray,…

xteetsx
- 43
- 8
0
votes
1 answer
Downloading Image does now work with NSURLSessionDataTask
I am migrating my deprecated iOS9 code to iOS10, specifically this:
@interface IconDownloader : NSObject{
NSMutableData *receivedData;
}
@property(nonatomic,strong)CapabilityType…

Josh
- 6,251
- 2
- 46
- 73