0

I can't seem to fetch from a valid URL database.

I have the following code:

print("calling")

    let session = NSURLSession.sharedSession()
    let url = NSURL(string: "valid url")
    let request = NSURLRequest(URL: url!)
    let dataTask = session.dataTaskWithRequest(request) { (data:NSData?, response:NSURLResponse?, error:NSError?) -> Void in
        print("done, error: \(error)")
    }
    dataTask.resume()
    print("end calling")

However, it seems as though the print within the request does not get output at all.

The only output I see is calling and end calling

What am I seem to be doing wrong with my implementation?

Thanks

Pangu
  • 3,721
  • 11
  • 53
  • 120

1 Answers1

0

I seem to have found the answer based on another post:

NSURLSession dataTaskWithRequest not being called

azimov was also right, it took a bit a time to execute.

Community
  • 1
  • 1
Pangu
  • 3,721
  • 11
  • 53
  • 120