Php json解析swift alamofire
我正在从mysql和php中获取数据,alamofire数据以json编码,这很好地响应了现在我想在tableview中解码和显示如何解析数据并在tableview中显示我搜索了许多示例,但没有找到如何在tableview中解码和显示数据的解决方案Php json解析swift alamofire,php,ios,json,swift,alamofire,Php,Ios,Json,Swift,Alamofire,我正在从mysql和php中获取数据,alamofire数据以json编码,这很好地响应了现在我想在tableview中解码和显示如何解析数据并在tableview中显示我搜索了许多示例,但没有找到如何在tableview中解码和显示数据的解决方案 <?php if($_SERVER['REQUEST_METHOD'] == "GET") { $conn = mysqli_connect("localhost","id1512305
<?php
if($_SERVER['REQUEST_METHOD'] == "GET")
{
$conn = mysqli_connect("localhost","id15123058_root2","Ioscrud/12345","id15123058_imageupload");
$query = mysqli_query($conn,"SELECT * FROM `ioscrud`");
while($fetch = mysqli_fetch_array($query))
{
$temp[] = $fetch;
}
$json['jobs'] = $temp;
$jsonformat = json_encode($json);
echo ($jsonformat);
}
?>
这是一节课
import UIKit
import Alamofire
class TableViewController: UITableViewController {
@IBOutlet var tableview: UITableView!
var product = [Product]()
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
// MARK: - Table view data source
// override func numberOfSections(in tableView: UITableView) -> Int {
// // #warning Incomplete implementation, return the number of sections
// return product.count
// }
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return product.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
let url = "https://jobportal475.000webhostapp.com/IosCrud/viewData.php"
AF.request(url,method: .get).response
{response in
debugPrint(response)
if response.data != nil
{
debugPrint(response)
}
}
cell.nameLabel.text = product[indexPath.row].name
cell.emailLabel.text = product[indexPath.row].email
cell.passwordLabel.text = product[indexPath.row].password
return cell
}
}
这里有一个指南库,如果你愿意,你可以使用它
或者你可以用这个
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?
saddr="+latitude_cur+","+longitude_cur+"&daddr="+latitude+","+longitude));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_LAUNCHER );
intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent)
事实上,由于你没有提供你的项目的任何代码,我不能帮助你,如果你分享你的代码,从那里你得到这些坐标,那么我可以帮助你
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?
saddr="+latitude_cur+","+longitude_cur+"&daddr="+latitude+","+longitude));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addCategory(Intent.CATEGORY_LAUNCHER );
intent.setClassName("com.google.android.apps.maps",
"com.google.android.maps.MapsActivity");
startActivity(intent)