对 ParseUser 或 ParseObject 使用 saveEventually() 而不是 save() 或 saveInBackground() [英] Using saveEventually() instead of save() or saveInBackground() for ParseUser or ParseObject

查看:18
本文介绍了对 ParseUser 或 ParseObject 使用 saveEventually() 而不是 save() 或 saveInBackground()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看 Parse 文档,有一个 saveEventually() 方法可以用来代替 save() 和 saveInBackground().

Looking at Parse documentation, there is a saveEventually() method that can be used in place of save() and saveInBackground().

我可以在我的代码中的任何地方使用这个函数来代替 save 和 saveInBackground 这样我就不必担心用户在离线和在线之间切换,而且我不必在没有的情况下处理保存连通性?使用这种方法有什么缺点吗?

Can I use this function everywhere in my code in place of save and saveInBackground so I don't have to worry about the user switching between being offline and online and I won't have to handle saving in situations where there is no connectivity? Are there any drawbacks to using this approach?

推荐答案

根据 Parse 的 iOS 指南:

According to Parse's iOS guide:

大多数保存功能会立即执行,并在保存完成时通知您的应用.如果您不需要知道保存何时完成,则可以改用 saveEventually.优点是如果用户当前没有网络连接,saveEventually 将在设备上存储更新,直到重新建立网络连接.如果您的应用在连接恢复之前关闭,Parse 将在下次打开应用时重试.

Most save functions execute immediately, and inform your app when the save is complete. If you don't need to know when the save has finished, you can use saveEventually instead. The advantage is that if the user currently doesn't have a network connection, saveEventually will store the update on the device until a network connection is re-established. If your app is closed before the connection is back, Parse will try again the next time the app is opened.

因此,如果您在保存完成后需要回调,您将使用 save.我认为您可以根据您处理的情况使用两者.

So you will use save if you need the callback when the save has finished. I think you can use both depending on the situation you are handling.

这篇关于对 ParseUser 或 ParseObject 使用 saveEventually() 而不是 save() 或 saveInBackground()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆