本文介绍了使用 PFFile(解析本地数据存储)最终保存在 PFObject 上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标

我正在尝试保存具有 PFFile 作为属性的 PFObject.我正在为 iOS 使用新的 Local Datastore,所以我想用 saveEventually() 方法保存这个 PFObject.

问题

我遇到的问题是 saveEventually() 方法似乎不喜欢保存 PFFiles.我尝试在没有附加任何 PFFile 的情况下 saveEventually() 我的对象,并且效果很好.一旦我的 PFFile 被重新附加,Xcode 就抛出了几个断点通知(错误?)但没有终止应用程序,看起来好像一切顺利 - 但是检查解析数据浏览器确认保存没有通过.

在使用本地数据存储功能之前,我不相信这种保存是可能的 - 它会抛出 无法最终保存与新的未保存的 PFFile 相关的 PFObject." 错误.本地数据存储功能似乎已修复此问题,正如 iOS 本地数据存储文档 中所述:>

"固定一个 PFObject 是递归的,就像保存一样,所以任何对象您正在固定的那个指向的也将被固定.当一个对象被固定时,每次你通过获取或保存新数据,本地数据存储中的副本将被更新自动地.你根本不需要担心."

我已将 SDK 更新到最新版本 (v1.6.2).有任何想法吗?

解决方案

PFFiles 仍然不支持 saveEventually 见这里

该页面最后更新时间:2015-01-23

您可以pinInBackgroundWithBlock,如果成功,将 PFFile 保存到您的应用程序包中的临时文件夹,并在必要或取消固定时将其删除

Goal

I am trying to save a PFObject that has a PFFile as an attribute. I am using the new Local Datastore for iOS, so I would like to save this PFObject with the saveEventually() method.

The Problem

The problem I am encountering is that the saveEventually() method doesn't seem to like saving the PFFiles. I tried to saveEventually() my object without any PFFile attached, and that worked fine. As soon as my PFFile was reattached, Xcode threw a couple of breakpoint notices (errors?) but did not terminate the app, and it appears as though all went well - however a check on the Parse Data Browser confirms that the save did not go through.

Prior to the Local Datastore feature I don't believe this save would have been possible - it would have thrown the "Unable to saveEventually a PFObject with a relation to a new, unsaved PFFile." error. It seems as though the Local Datastore feature has fixed this, as it states in the iOS Local Datastore docs:

I have updated the SDK to the latest version (v1.6.2). Any ideas?

解决方案

PFFiles still don't support saveEventually see here

That page was last updated : 2015-01-23

You could pinInBackgroundWithBlock and if successful save the PFFile to a temporary folder in you app bundle and delete it when necessary or unpinned

这篇关于使用 PFFile(解析本地数据存储)最终保存在 PFObject 上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 03:59
查看更多