2017-10-04 67 views
0

正是標題所說的。我收到了這個錯誤,並且不確定這是否與Swift 4轉換有關。我一直在努力解決代碼,但沒有運氣,所以決定把這個問題放在SO上。是越來越拋出這個錯誤就行: 「cell.businessPostImage.setImageWith(postRequest,」 感謝Swift 4錯誤:「無法將類型'URLRequest'的值轉換爲期望的參數類型'URL!'」

cell.businessPostImage.image = nil 
     if let postURL = URL(string: downloadURL) { 
      let postRequest = URLRequest(url: postURL) 
      cell.businessPostImage.setImageWith(postRequest, placeholderImage: nil, options: 
      { (imageRequest, imageResponse, image) in 
        cell.businessPostImage.contentMode = UIViewContentMode.scaleToFill 
        cell.businessPostImage.image = image 
      }, completed: { (imageRequest, imageResponse, error) -> Void in 
       // failure downloading image 
       print("Error downloading Firebase post image") 
       print(error) 
      }) 
     } 

This is the error its getting thrown WITH the edit

+0

通在'postURL ''而不是'postRequest'。 – rmaddy

+0

請檢查我剛剛添加的錯誤,因爲編輯引發了新的錯誤 –

+0

您正嘗試將一個閉包傳遞給'options'參數 – rmaddy

回答

1

你必須使用這樣的:。

if let postURL = URL(string: downloadURL) { 
    let postRequest = URLRequest(url: postURL) 
    cell.businessPostImage.setImageWith(postURL, placeholderImage: nil, options: SDWebImageOptions.ProgressiveDownload, completed: { (imageRequest, imageResponse, error) -> Void in 
     // failure downloading image 
     print("Error downloading Firebase post image") 
     print(error) 
    }) 
} 
相關問題