используйте обычный код для TVCell:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: REUSE_ID, for: indexPath) as! TripTableViewCell
// Configure the cell...
let row = indexPath.row
// take a part fo url..
let title = ...[row]
cell.textLabel.text = title
....
Например, вы можете:
.. url = URL (строка: "https://api.myjson.com/bins/oe3gu")
let title = url.lastPathComponent
, если «oe3gu» достаточно.
Я предпочту:
class TableViewController: UITableViewController {
typealias InfoTuple = (String,String)
let myInfo :[InfoTuple] = [
("https://api.myjson.com/bins/oe3gu" , "link 1"),
("https://api.myjson.com/bins/oe3gu2" , "link 2"),
("https://api.myjson.com/bins/oe3gu2" , "link 3"),
]
override func viewDidLoad() {
super.viewDidLoad()
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return myInfo.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)
// Configure the cell...
let row = indexPath.row
let (title, _) = myInfo[row]
cell.textLabel?.text = title
return cell
}
....
и ваш код будет:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let row = indexPath.row
let (_, url) = myInfo[row]
let task = URLSession.shared.dataTask(with: url!) {
data, responese, error in
.....
}