func webService() {
let url = NSURL(string: "http://")
let request = NSURLRequest(URL: url!)
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config)
let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in
// notice that I can omit the types of data, response and error
do{
if let jsonResult = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers) as? NSDictionary {
//print(jsonResult)
let toLocation = jsonResult.objectForKey("TripData")!.valueForKey("TO_LOCATION")
//print(routes)
let loc=toLocation! .objectAtIndex(0)
print(loc)
}
}
catch{
print("Somthing wrong")
}
});
// do whatever you need with the task e.g. run
task.resume()
}
Sign up here with your email
ConversionConversion EmoticonEmoticon