Reputation: 652
I'm trying to get a string to pass to an NSURL but it returns
"NSURL? unable to read data"
Here is my code:
let urlPath: String = "http://test.com/get.php"
let url: NSURL =NSURL(string: urlPath)!
let request: NSURLRequest = NSURLRequest(URL: url)
let connection: NSURLConnection = NSURLConnection(request: request, delegate: self, startImmediately: true)!
connection.start()
Upvotes: 0
Views: 3350
Reputation: 3765
This is a common issue that occur when running on simulators. Run a device and you should see that the NSURL
was created properly.
Upvotes: 0
Reputation: 50089
let urlPath: String = "http://test.com/get.php"
let url: NSURL =NSURL(string: urlPath)!
this works.
Upvotes: 0