首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过getDataInBackgroundWithBlock检索PFFile时出错

通过getDataInBackgroundWithBlock检索PFFile时出错
EN

Stack Overflow用户
提问于 2015-06-08 13:31:48
回答 1查看 285关注 0票数 2

我已经创建了一个var userImages = [PFFile](),并通过用户查询和self.userImages.append(user["imageFile"] as! PFFile)从解析中添加了相应的用户图像。这可以很好地工作。但是,当我尝试通过

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

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

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

谢谢你的帮助!!

EN

回答 1

Stack Overflow用户

发布于 2015-06-08 13:37:50

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

代码语言:javascript
复制
userImages.last?.getDataInBackGroundWithBlock{...}

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

代码语言:javascript
复制
let userImage = user["imageFile"] as! PFFile
userImage.getDataInBackGroundWithBlock{...}

或者使用以下命令直接访问:

代码语言:javascript
复制
(user["imageFile"] as! PFFile).getDataInBackGroundWithBlock{...}

角色流程是:

代码语言:javascript
复制
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
    }
  }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30701825

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档