Questions tagged [nsurlsessiondatatask]

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

265 questions
0
votes
1 answer

Swift - malformed data when sending a dictionary to server

During server development I was using cURL to test data being posted. Now I’m developing on the client side and the data being returned form the server seems malformed. First, I’ll show you what I was sending with cURL: curl -X PUT --data…
Adam Carter
  • 4,741
  • 5
  • 42
  • 103
0
votes
1 answer

NSJSONSerialization Not Getting Called - Objective C

I am trying to populate the TableViewCells in my TableViewContoller with an Array of data that is being pulled from a JSON object. NSJSONSerialization is simply not getting called. I've tried a variety of things using DataTaskWithURL. Sadly I'm…
0
votes
3 answers

Function completes before NSURLSession - dataTaskWithRequest completed

I have the following method called under ViewDidLoad(). I understand that session.dataTaskWithRequest automatically runs in background thread. And because of the same, the code following this method in ViewDidLoad() does not wait for this process to…
PK20
  • 1,066
  • 8
  • 19
0
votes
1 answer

AFHTTPSessionManager post request

I want to post a request to server. It is working fine if I am using NSURLSessionDataTask. But underneath I need to use AFNetworking as my whole application is using it. But when I am trying to hit the same service in AFHTTPSessionManager with POST…
user1071309
  • 61
  • 1
  • 7
0
votes
0 answers

NSURLSession with multiple HTTP requests

I want to send multiple HTTP requests (one after the other) in Swift using NSUrlSession, I am trying to login to a web page so I need to send a GET request and use the cookie for the following POST request and then use that authentication cookie to…
reut
  • 21
  • 9
0
votes
1 answer

Return NSURLSession response to its calling function

I have written two following functions for using NSURLSession. func getStringFromRequest(completionHandler:(success:Bool, data: NSData?) -> Void) { let prefs = NSUserDefaults.standardUserDefaults() var conn_timeout =…
Amit Raj
  • 1,358
  • 3
  • 22
  • 47
0
votes
1 answer

NURLSession batch requests with block. Post parameters changed

- (void)someMethodThatIsCalledTwice{ NSURLSession *session = [NSURLSession sharedSession]; NSString *noteDataString = [NSString stringWithFormat:@"album_id=%@&pic_id=%@", albumId,photoId]; NSURL *url = [NSURL…
0
votes
1 answer

How do I convert this curl command to Objective-C?

I want to get data from my backend. I should set a request header with Authorization and use the generate auth_token from my previous interaction to the backend. here it is my curl curl -H 'Authorization: Token token="replace-with-token"'…
MKH
  • 153
  • 1
  • 3
  • 15
0
votes
2 answers

Does Apple test iOS apps offline? How to handle error if no connection?

I have submitted an app to iTunes and Apple rejected it because of a crash. I symbolicated and analyzed the crashreport and saw that it crash at a json call. I try to reproduce it and I found that it just happens when I turn off my wlan. Does Apple…
BHuelse
  • 2,889
  • 3
  • 30
  • 41
0
votes
1 answer

NSURLSessionDataTask show loading overlay

How to make a loading overlay with a spinner when doing async task with NSURLSessionDataTask?
user3691709
  • 131
  • 3
  • 8
0
votes
1 answer

Swift: How to loop through NSURLSession with different NSURL orderly?

Basically I want to loop through 4 web pages, obtaining 6 data from each page, having a total of 24 data in an array at the end of the loop, then display the last added data of that array (the 24th object in the array) / (the 6th data of the 4th web…
Allister Bah
  • 1,134
  • 3
  • 13
  • 19
0
votes
0 answers

Prevent NSURLSessionDataTask from repeatedly firing request

I am using a NSURLSessionDataTask to get JSON data from a device that opens an adhoc-WiFi which is joined by an iPhone. (The connection is running via TCP). The device is pretty slow - it takes roundabout 5sec to send the particular response. After…
benrudhart
  • 1,406
  • 2
  • 13
  • 25
0
votes
1 answer

UIAlertView takes too long when using inside NSURLSession

I am using NSURLSession to get some information from my server. After i get the data, i show it in a UIAlertView, but it takes too long to show. I print the data with the NSLog and it prints it almost instantly... So what is happening? Does the…
Fernando Santiago
  • 2,128
  • 10
  • 44
  • 75
0
votes
1 answer

How can I obtain data from consecutive URLs

I have consecutive Url's up to page number when I try to execute in a loop it does not work here is my code I want to get data from different URLs up to page number for(var i = 1 ; i < 50; i ++) { var pageNumber = 1 var urlPath =…
0
votes
2 answers

Run 3 methods one after each other

I need to run 3 methods one after each other in a seperate thread that calls an api (NSURLSessionDataTask async). I have looked into dispatch groups but this seems to run method 1 and 2 at the same time and then runs method 3 when they finish:…