我正在使用 swift 和 Parse Framework (1.6.2)。我将数据存储到本地数据存储中。数据由几个字符串和一个图像组成。此图像将存储在 PfFile 中,然后将添加到 PfObject。
现在我想知道为什么图像没有被保存,直到我注意到我需要调用 PFFile 的 save() 方法。问题是图像似乎被上传到我不想要的 Parse。我希望它存储在本地设备上..
有解决方案吗?
谢谢
编辑:
代码是这样工作的:
var spot = PFObject(className: "Spot")
let imageData = UIImageJPEGRepresentation(spotModel.getPhoto(), 0.05)
let imageFile = PFFile(name:"image.jpg", data:imageData)
spotObj.setObject(spotModel.getCategory(), forKey: "category")
spotObj.setObject(imageFile, forKey: "photo")
//if I simply would do this, the PFObject will be saved into the local datastorage, but the image won't be saved
spotObj.pin()
//if I do this, the image will be saved also BUT it won't be saved into the local data storage but will be uploaded to parse
imageFile.save()
spotObj.pin()