raj kumar raj kumar - 1 month ago 9
JSON Question

How to parse json latitude and longitude via cell in swift

I am developing an app using Swift-2. I am parsing JSON data to table view. On tapping a cell, it moves to another view controller and fetching data. Everything works fine but the problem is when I don't know how to parse latitude and longitude from JSON data which am getting from the server.

Code in my first controller:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

TableView.deselectRowAtIndexPath(indexPath, animated: true)

let tripcontroller = self.storyboard?.instantiateViewControllerWithIdentifier("UpcomingController") as! UpcomingController

let strbookdetail : NSString=arrDict[indexPath.row] .valueForKey("customer_name") as! NSString

let strdrop : NSString=arrDict[indexPath.row] .valueForKey("customer_phno") as! NSString

tripcontroller.dataFromBeforeVC = ["strbookdetail":strbookdetail as String, "strdrop":strdrop as String]

navigationController?.pushViewController(tripcontroller, animated: true)}

//it helps when tapping the cell moves to other controller and fetching data

code in second controller:

//here i wrote some functions and methods for updating current location and fetching some data when tapped a cell

func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

//i know that here only i need to parse json lat and long so HELP me to parse

Data from the server:












from that JSON data i want show annotation with pick and drop


I got a answer for my question:

i just pass the latitude and longitude in func didselect method as nsstring

In func didupdate location method:

I just convert the string into double like Double(["latitude"])

This works for me