我正在用Swift-2开发一个应用程序。我正在将JSON数据解析为表视图。在点击一个单元格时,它移动到另一个视图控制器并获取数据。一切都很好,但问题是当我不知道如何从从服务器获得的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
来自服务器的数据:
{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"
}]}
从那个JSON数据中,我希望显示带有选择和删除的注释
发布于 2016-11-24 06:57:41
我的问题有了答案:
我只是将func中的纬度和经度传递为nsstring。
在func didupdate定位方法中:
我只是把字符串转换成双(“纬度”)
这个对我有用
https://stackoverflow.com/questions/40741708
复制相似问题