2017-06-30 78 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欢迎伴侣:) –

相关问题