2017-06-30 117 views
1

這段代碼本可以在幾個月前工作,我在GitHub上檢查了一些其他代碼,並驗證了這段代碼在過去可行,但是我很難找到一個辦法。我已經使用Firebase Migration Support尋找解決方案,但我沒有運氣。先謝謝你!'StorageReference'類型的值沒有成員'data'

func configCell(searchDetail: Search) { 

    self.searchDetail = searchDetail 

    nameLbl.text = searchDetail.username 

    let ref = Storage.storage().reference(forURL: searchDetail.userImg) 

    //Error Below, highlighting 'ref.data' Error: Value of type 'StorageReference' has no member 'data'. 

    ref.data(withMaxSize: 1000000, completion: { (data, error) in 

     if error != nil { 

      print(" we couldnt upload the img") 

     } else { 

      if let imgData = data { 

       if let img = UIImage(data: imgData) { 

        self.userImage.image = img 
       } 
      } 
     } 

    }) 
} 

回答

5

從您已經添加的遷移指南,您需要現在使用的新getData(maxSize:completion:)代替data(withMaxSize:completion:)。所以就這樣做吧。

ref.getData(maxSize: 1000000, completion: { (data, error) in 

    if error != nil { 

     print(" we couldnt upload the img") 

    } else { 

     if let imgData = data,let img = UIImage(data: imgData) { 
      self.userImage.image = img 
     } 
    } 

}) 
+0

噢,我的天啊,非常感謝。對不起,沒有捕捉到。 –

+0

@ AladdinAl-Khatib歡迎伴侶:) –

相關問題