我想知道是否有人可以帮助我,我是应用程序开发的新手
我正在从我的应用程序上传图像以在解析文档的帮助下毫无问题地进行解析。
let imageData = UIImagePNGRepresentation(scaledImage)
let imageFile: PFFile = PFFile(data: imageData)
var userPhoto = PFObject(className: "postString")
userPhoto["imageFile"] = imageFile
userPhoto.saveInBackground()
但是当我添加代码来检索图像时,我有点迷失了:/
let userImageFile = anotherPhoto["imageFile"] as PFFile
userImageFile.getDataInBackgroundWithBlock {
(imageData: NSData!, error: NSError!) -> Void in
if !error {
let image = UIImage(data:imageData)
}
}
“另一个照片”来自哪里? Parse 确实说“在这里我们从另一个名为 anotherPhoto 的 UserPhoto 检索图像文件:”
anotherPhoto
将是你的一个实例postString
(userPhoto
在您的上传示例中)。适合您的文件下载示例如下:
let userImageFile = userPhoto["imageFile"] as PFFile
userImageFile.getDataInBackgroundWithBlock {
(imageData: NSData!, error: NSError!) -> Void in
if !error {
let image = UIImage(data:imageData)
}
}
任何 PFFile 都必须从普通 PFObject 引用,否则无法检索。 PFFile 对象本身不会显示在数据浏览器中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)