Hy, I am new to swift and I am doing work on nsurlsession. Here is my code
func webRequestToServer() {
let request = NSURLRequest(URL: NSURL(string:"some url")!)
let urlSession = NSURLSession.sharedSession()
let task = urlSession.dataTaskWithRequest(request, completionHandler: {
(data, response, error) -> Void in
if let error = error {
print(error)
return }
// Parse JSON data
if let data = data {
let dataString = NSString(data: data, encoding: NSUTF8StringEncoding)
print(dataString)
NSOperationQueue.mainQueue().addOperationWithBlock({ () -> Void in
})
} })
task.resume()
}
Thus from this code the data arrives from the websrvice but I want to do that first it takes two parameters from me and then show data? please help me. Sorry for my English. It's weak.