-1
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let firstPart = URL(string: "https://www.kiva.org/lend/")
        let secondPart = loans[indexPath.row].id

        let result = firstPart + secondPart
        UIApplication.shared.openURL(result as URL)
    }

error: Binary operator cannot be applied to two url operands

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
  • 1
    Lookup the [URL documentation](https://developer.apple.com/documentation/foundation/url). It has methods to (hint!) *append a path component.* – Martin R Jul 11 '17 at 11:50

2 Answers2

3

You should append the strings to each other and make that a URL.

let urlString = "https://www.kiva.org/lend/" + loans[indexPath.row].id
let url = URL(string: urlString)
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
0

i "broke my head", but i fixed my mistake

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let firstPart = URL(string: "https://www.kiva.org/lend/\(loans[indexPath.row].id)")
    UIApplication.shared.openURL(firstPart!)