2016-11-22 10 views
0

私はSwift-2を使ってアプリケーションを開発しています。 JSONデータをテーブルビューに解析しています。セルをタップすると、別のビューコントローラに移動してデータを取得します。すべて正常に動作しますが、問題は、サーバーから取得している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データから私が注釈を表示したいですピックアンドドロップ

+0

のために働く

してみてください、このitem.objectAtIndex(インデックス).objectForKey(piclat)? NSNumber –

+0

私はそれをチェックし、あなたの応答に感謝します –

答えて

0

私は私の質問のための答えだ:私はちょうどFUNC didupdate場所方法で

をNSStringのようにfunc didselect方法で緯度と経度を渡し

を:

私はちょうど(ダブルのように二重に文字列を変換します[ "緯度"])これは私

関連する問題