Questions tagged [nsurlsessiondatatask]

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

249 questions
-1
votes
1 answer

NSURLSessionDataTask cancel and Core Data

I've got NSURLSession, that downloads new user profiles from server, then for each profile downloads array of photos, and than stores in Core Data. Every time the user reaches this screen i stop downloading tasks, clear Core Data, than fill it…
Nikita Semenov
  • 2,011
  • 3
  • 15
  • 28
-2
votes
1 answer

A question about URLSessionDataTask and Combine in Swift

In an article, I saw a code snippet like below: extension URLSessionDataTask: Cancellable {} extension URLSession: NetworkService { public func fetchData(with request: URLRequest, handler: @escaping (Data?, URLResponse?, Error?) -> Void) ->…
spencerfeng
  • 347
  • 4
  • 14
-2
votes
1 answer

Why URLSession.DataTask.shared is not working properly?

I need to fetch some quizzes for my application from the server. Unfortunately, it seems that URLSession.DataTask.shared is not working. How do I fix the problem? This is for Swift 4. import Foundation import UIKit class QuizService { let…
D.J.
  • 1
-2
votes
1 answer

JSON Parsing dataTaskWithUrl returns 0 bytes of data

Hi I'm trying to retrieve data from url. So I'm using dataTask with url. THe response received is showing as 0 bytes but the I print it shown around 46171 bytes of data in upperbound...please find below screen shot. Because of this im not able to…
Ashh
  • 429
  • 1
  • 5
  • 22
-2
votes
2 answers

Could not decode JSON: The data couldn’t be read because it isn’t in the correct format

UPDATE I get the error "Error! Could not decode JSON: The data couldn’t be read because it isn’t in the correct format.". The JSON from the request is…
nullx
  • 42
  • 1
  • 6
-2
votes
4 answers

How to print the web service request and response from dataTaskWithRequest

Can anyone guide me how to print the web service request and response from dataTaskWithRequest in json format while using swift 4.0 and objective C. Links tried: How to print NSMutableURLRequest? I can print them, but its not printing in proper…
Prajnaranjan Das
  • 1,206
  • 1
  • 9
  • 22
-2
votes
1 answer

NSURLSessionDataTask in appdelegate

I would call a NSURLSessionDataTask in appDelegate when the app is open from mail, so in this function - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation I…
-2
votes
2 answers

How to delete a json object from server?

I write a code that get recipes in form of JSON from a server and present it into a UItable. NSURL *url = [NSURL URLWithString:@"http://domain.com/recipes"]; [config setHTTPAdditionalHeaders:@{@"Authorization":@" Token…
MKH
  • 153
  • 2
  • 14
-9
votes
2 answers

Get Current Progress from URLSession.shared.dataTask

I need to get current progress (received and total bytes) of the data task for GET request to make a progress loading indicator from this data.
1 2 3
16
17