Swift 3 – 在Safari中从JSON打开URL

我目前有一个移动应用程序,从JSON文件中带来的项目列表。 JSON文件也有附加到每个项目的URL列表。 当用户触摸列表视图中的项目时,我需要在Safari中打开URL。

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) cell.textLabel?.text = TableData[indexPath.row] return cell } 

有没有人有关于如何做到这一点的想法,我可以张贴代码来显示如何在必要时带入数据列表。

添加以下代码:

 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { UIApplication.sharedApplication().openURL(NSURL(string:TableData[indexPath.row])!) }