- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我创建了一个 var userImages = [PFFile]()
并通过用户查询和 self.userImages.append(user["imageFile"] 作为 !PFFile)
。这很好用。但是,当我尝试通过
userImages.getDataInBackGroundWithBlock{ (data, error) -> Void in ...
我收到以下错误:**“[(PFFile)]”没有名为“getDataInBackGroundWithBlock”的成员**
为什么这行不通,什么可能是这个问题的解决方案?
谢谢你的帮助!!
最佳答案
您正在尝试在数组中调用 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
}
}
}
关于swift - 通过 getDataInBackgroundWithBlock 检索 PFFile 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30701825/
我尝试过使用其他解决方案,但没有成功。我需要将数据保存到 UIImages 数组中,因此在创建单元格时,它只需从一组已制作的图像中分配图像。问题是它返回零。另外,我需要确保图像是有序的。 /--UPD
我正在从我的 Parse 类中获取一个字符串、NSDate 和一个 PFFile 来填充 Collection View 单元格 所有单元格都正确加载图像、日期和信息。信息和日期的排序正确(按日期升序
所以我使用解析将一些对象保存到 localDatastore。 //Pin the objects here!! var imageObject = PFObject(className: "img"
我创建了一个 var userImages = [PFFile]() 并通过用户查询和 self.userImages.append(user["imageFile"] 作为 !PFFile)。这很好
我有一个 updateCell 函数,我在 tableView 函数中调用它。 我正在尝试更新单元格并将 PFFile 转换为 UIImage,但我不断收到错误无法将类型“(NSData?, NSEr
我正在尝试从 Parse 查询图像,但我继续遇到 fatal error: unwrapping optional value unwrapping optional value.我不确定这是否与最近
我正在编写一个使用托管在 Heroku 上的 Parse 的快速 iOS 应用程序。据我所知,所有数据传输都是通过 HTTPS 进行的,我没有对 info.plist 进行 App Transport
我正在努力提高我的 UICollectionView 加载时间的性能。我正在使用 Parse 来存储我的所有数据,我的问题是我是否应该考虑将 GCD 与 Parse 结合使用? 目前,我正在使用以下方
我正在使用 swift 6.3 并且有 2 个类似的错误 无法使用类型为“(([AnyObject]!, NSError!) -> Void)”的参数列表调用“findObjectsInBackgro
我是一名优秀的程序员,十分优秀!