Questions tagged [nsurlsessiondatatask]

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

249 questions
0
votes
2 answers

Store NSURLSessionDataTask response to SQLite database?

My code calls HTTP post call to remote server and obtains results in JSON format, I have extracted this JSON, but now I need to store these results to SQLite. Based on my reading NSURLSessionDataTask is background thread, so my confusion is, should…
kosa
  • 63,683
  • 12
  • 118
  • 157
0
votes
1 answer

Go to another view when NSURLSession finishes its job

My problem is when I try to go another view after some api call finishes, it wont go to the next view. Here is the code below. Thanks in advance. var task = NSURLSession.sharedSession().dataTaskWithURL(url!, completionHandler: { (data, response,…
0
votes
1 answer

NSURLSessionDataTask in App Delegate

I am trying to run a NSURLSessionDataTask in my app delegate on a background fetch but although I get valid data from the completion handler the app isn't firing the method. Here is my code - (void)application:(UIApplication *)application…
Joe Barbour
  • 834
  • 9
  • 14
-1
votes
1 answer

the code is not entering the completion handler of the data task

The completion handler code is not getting executed. while i debug the code its coming till the session.datatask and after that its not getting into the completion handler. we are actually migrating this project from objectivec to swift. i am not…
-1
votes
1 answer

Getting an error when trying to download an image

I am trying to download an image using the following code: if let imageUrl = post.postImageURL{ let url = NSURL(string: imageUrl) URLSession.shared.dataTask(with: url!, completionHandler: {(data, response, error) in if…
-1
votes
1 answer

Adding a completion handler to an asynchronous request method that only returns completion

So I've posted twice on this and I'm still pretty stuck (post 1, post 2). I want to trigger an authentication request when if I get a 401 challenge when calling another request. I have a completion block for my request so it receives the data and…
Axemasta
  • 604
  • 8
  • 21
-1
votes
3 answers

How to fetch JSON data in chain of links and put it to the same model?

I don't know how to put it correctly so I will show in pictures. I create first URLSession, fetch data from JSON, including links to data I want to use in the same Model. first link: From first request I got links to other info I want to use in…
odvan
  • 59
  • 2
  • 8
-1
votes
1 answer

NSURLSession (iOS 10) cut response from a server

I have wrote this code to do an HTTP request to a server that sends to me a json string: -(NSDictionary*)doRequestWithCommand:(NSString*)command andBody:(NSString*)requestBody { __block NSDictionary *result = nil; NSURL *URL = [NSURL…
frank
  • 15
  • 3
-1
votes
1 answer

iOS 10 - NSURLSession is very slow compared to iOS 9

I've a service which gives JSON response of about 15000 records. When calling that service in iOS 9 (iPad Air) using NSURLSession dataTask its taking 2 to 3 minutes, but the same service is taking 10 to 12 minutes in iOS 10. Has anyone come across…
i 4322946
  • 153
  • 2
  • 8
-1
votes
1 answer

Unexpected non-void return value in void function - JSON Data from dataTask(with: URL) - (Swift 3.0)

I'm building an iOS app in Swift 3 that's supposed to communicate with a JSON Rest Api that I'm also building myself. The app will get all sorts of content from the Api, but for now all I need it to do is check the availability of the Api through a…
-1
votes
1 answer

NSURLSessionDataTask call not working in objective c?

I am executing following code when app is not running after click on "Actionable notification" button.i enabled background mode,remote-notification. //base url is changed for privacy purpose NSMutableURLRequest *request = [NSMutableURLRequest…
Avijit Nagare
  • 7,801
  • 7
  • 34
  • 62
-1
votes
2 answers

Swift 2 OSX How do I use a loop at the end of a series of completions which includes a data task?

I'm using completion blocks for each of my functions (to avoid using a while isDoingSomething loop). I get the expected array when all the blocks complete. But when I try to loop through this final array, it loops continually as expected but…
dbconfession
  • 1,017
  • 1
  • 19
  • 35
-1
votes
1 answer

NSURLSessionDataTask return data in completion handler, Swift 2.0

I've read several other questions about this same issue, but somehow the completion handler works different for the other answers. Also, those answers are from 2015, which makes me wonder if its specific to Swift 1.x Anyways, here's my issue. I'm…
TooManyEduardos
  • 3,516
  • 5
  • 28
  • 61
-1
votes
1 answer

How to execute multiple NSURLSessionDataTask serially?

In my case, when an App launches, I want to call 3 web APIs using NSURLSessionDataTask. I have 3 different methods for each API and inside each method, there is one NSURLSessionDataTask. I want to shape my code in such a way that these 3 methods…
-1
votes
3 answers

How to wait for async calls to finish

I am running three API calls using the Spotify API, in order to get the following data and store them into my Artist object: The artist. That artist's albums. Tracks of each albums of the artist. Once they are done, I would like to pass the…
Sean Calkins
  • 217
  • 2
  • 9
1 2 3
16
17