2

我已经创建了一个var userImages = [PFFile]()并通过用户查询从 Parse 附加了相应的用户图像和self.userImages.append(user["imageFile"] as! PFFile). 这工作正常。但是,当我尝试通过

userImages.getDataInBackGroundWithBlock{ (data, error) -> Void in ...

我收到以下错误:**'[(PFFile)]' does not have a member named 'getDataInBackGroundWithBlock'**

为什么这不起作用,这个问题的解决方案可能是什么?

感谢您的帮助!!

在此处输入图像描述

在此处输入图像描述

4

1 回答 1

1

您正在尝试调用getDataInBackGroundWithBlock数组尝试使用“

userImages.last?.getDataInBackGroundWithBlock{...}

或者您可以将其保存在变量中并使用新的 PFFIle 检索图像

let userImage = user["imageFile"] as! PFFile
userImage.getDataInBackGroundWithBlock{...}

或直接使用:

(user["imageFile"] as! PFFile).getDataInBackGroundWithBlock{...}

角色流程为:

self.userImages.append(user["imageFile"] as! PFFile) //This is just a reference to download the image

userImages.last?.getDataInBackgroundWithBlock {
  (imageData: NSData?, error: NSError?) -> Void in
  if error == nil {
    if let imageData = imageData {
        let image = UIImage(data:imageData) // this is the final image
    }
  }
}
于 2015-06-08T05:37:50.140 回答