PFFile内的图像将被上传到parsing,而不是被保存到本地数据存储
我使用了parsing框架(1.6.2)的swift。 我正在将数据存储到本地数据存储中。 数据由几个string和一个图像组成。 这个图像将存储在一个PfFile中,然后将被添加到PfObject中。
现在我想知道为什么图像不能保存,直到我注意到我需要调用PFFile的save()方法。 问题是,图像似乎上传到我不想要的parsing。 我希望它被存储在本地设备上..
有这个解决scheme吗?
谢谢
编辑:
代码的工作原理是这样的:
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()
好的,看看这里用PFFile(parsing本地数据存储)最终保存PFObject? 。 一个这是肯定的,如果你打电话保存PFFile它会得到保存到在线数据存储。 所以你应该使用PFFile.save()。 我认为你最好的select是将文件保存在某个文件夹中。 并在PFObject中保存该path。 parsing文档只是说这个
"Pinning a PFObject is recursive, just like saving, so any objects that are pointed to by the one you are pinning will also be pinned. When an object is pinned, every time you update it by fetching or saving new data, the copy in the local datastore will be updated automatically. You don't need to worry about it at all."
它在你的主PFObject的其他对象上recursion调用.pin()。 但是,如果你看看PFFile API doc,那么它有一个.pin(),这意味着它不支持将PFFile保存到本地数据存储。 所以我会说你应该把它们保存在某个目录中,并保存PFObject的path。
更新
save: Saves the file synchronously and sets an error if it occurs. - (BOOL)save:(NSError **)error Parameters error Pointer to an NSError that will be set if necessary. Return Value Returns whether the save succeeded.
- 正在调用read:maxLength:每个NSStreamEventHasBytesAvailable都正确一次?
- MC系统组容器和MC从公共有效的用户设置中读取键盘外观错误
- 如何在UITextView中加载HTML?
- 如何在embedded在UINavigationController中的UISearchController中添加范围button
- 在使用PhoneGap构build的iPhone应用程序中加速jQuery Mobile 1.1中的页面转换?
- 适用于React Native iOS开发的My Development Toolset 2019
- 从与索引path相关的互联网上的Xcode中获取错误
- 在具有ios键盘扩展名的设备上运行Xcode Instruments
- 获取结果时发生崩溃控制器在保存后台MOC后更新表