0
我正在使用Swift-2開發一個應用程序。我正在解析JSON數據到表視圖。在點擊一個單元格時,它將移動到另一個視圖控制器並獲取數據。一切工作正常,但問題是,當我不知道如何解析來自服務器的JSON數據的經度和緯度。如何在swift中通過單元格解析json緯度和經度
代碼在我的第一個控制器:
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
碼在第二控制器:
//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
來自服務器的數據:從JSON數據
{item:[{
picklat:"9.322334",
picklong:"78.24524",
droplat:"9.253634",
droplong:"78.56245"
},{
picklat:"8.245234",
picklong:"67.456434",
droplat:"8.4567865",
groplong:"67.465785"
}]}
我想顯示批註與挑剔
試試這個item.objectAtIndex(指數).objectForKey(piclat)作爲? NSNumber –
我會檢查並回復感謝您的回覆 –