首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何通过单元格解析json纬度和经度

如何通过单元格解析json纬度和经度
EN

Stack Overflow用户
提问于 2016-11-22 12:19:21
回答 1查看 428关注 0票数 0

我正在用Swift-2开发一个应用程序。我正在将JSON数据解析为表视图。在点击一个单元格时,它移动到另一个视图控制器并获取数据。一切都很好,但问题是当我不知道如何从从服务器获得的JSON数据中解析纬度和经度时。

我的第一个控制器中的代码:

代码语言:javascript
运行
复制
 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

第二控制器中的代码:

代码语言:javascript
运行
复制
 //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

来自服务器的数据:

代码语言:javascript
运行
复制
{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数据中,我希望显示带有选择和删除的注释

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-24 06:57:41

我的问题有了答案:

我只是将func中的纬度和经度传递为nsstring。

在func didupdate定位方法中:

我只是把字符串转换成双(“纬度”)

这个对我有用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40741708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档