2017-07-11 12 views
-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二項演算子

+1

検索[URLのドキュメント](https://developer.apple.com/documentation/foundation/url)私のミスを修正しました。それには、(ヒント!)*パスコンポーネントを追加するメソッドがあります。 –

答えて

3

let urlString = "https://www.kiva.org/lend/" + loans[indexPath.row].id 
let url = URL(string: urlString) 
0

私は "私の頭を壊した"、しかし、私は

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!)