- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在开发一个 iPhone 应用程序,它利用 CloudKit 在用户设备之间同步应用程序数据。我使用 CoreData 作为我的本地缓存,以确保该应用在设备离线时仍然可用。
在开发过程中,我遇到了有关设备离线时同步行为的问题。让我举个例子来解释一下:
Person
(我正在处理的一个实体)CKRecord
以匹配本地缓存实体的数据CKRecord
保存到 CloudKit,创建了一个 CKModifyRecordsOperation
并设置了所有需要的完成 block 和属性CKModifyRecordsOperation
添加到数据库如果设备有可用的网络连接,则根据需要创建 CKRecord
。但是,当操作因网络连接不良而失败时,不会创建 CKRecord
。
假设设备保持离线状态,用户决定再次删除此人。这对于设备本地缓存的数据来说是没有问题的。但由于本地缓存没有关联CKRecordID
,因此无法创建CKModifyRecordsOperation
来删除云端的CKRecord
。
现在设备建立了网络连接并再次在线。所以现在执行创建 Person
-Entity 的 CKModifyRecordsOperation
。这会导致本地缓存和云端不同步。
我想通过跟踪与Person
-Entity 相关的未决操作来解决这个问题。如果此人被删除,则待处理的操作将被取消。
不幸的是我无法运行它。因此,如果我走在正确的轨道上,我将不胜感激!
谢谢!
最佳答案
尝试调整操作的 .qualityOfService
属性。根据位于 https://developer.apple.com/library/content/documentation/Performance/Conceptual/EnergyGuide-iOS/PrioritizeWorkWithQoS.html#//apple_ref/doc/uid/TP40015243-CH39 的 Apple 文档:
User-interactive: Work that is interacting with the user, such as operating on the main thread, refreshing the user interface, or performing animations. If the work doesn’t happen quickly, the user interface may appear frozen. Focuses on responsiveness and performance. Work is virtually instantaneous.
User-initiated Work that the user has initiated and requires immediate results, such as opening a saved document or performing an action when the user clicks something in the user interface. The work is required in order to continue user interaction. Focuses on responsiveness and performance. Work is nearly instantaneous, such as a few seconds or less.
Utility Work that may take some time to complete and doesn’t require an immediate result, such as downloading or importing data. Utility tasks typically have a progress bar that is visible to the user. Focuses on providing a balance between responsiveness, performance, and energy efficiency. Work takes a few seconds to a few minutes.
Background Work that operates in the background and isn’t visible to the user, such as indexing, synchronizing, and backups. Focuses on energy efficiency. Work takes significant time, such as minutes or hours.
该页面还表示默认值介于 user-initiated
和 Utility
之间。
根据 Apple 开发论坛上的讨论 https://forums.developer.apple.com/thread/20047 ,用户报告没有收到离线时失败的查询错误,就像您看到的那样,这些查询似乎实际上是持久存在的,并在连接恢复时再次尝试。该线程中的用户报告说,将 QoS 参数更改为 User-initiated
会导致在由于没有网络而无法完成操作时立即返回错误。
还显示,当操作被持久化时,操作的 longLivedOperationWasPersistedBlock
将被调用。
因此,选项 1:尝试将操作的 QoS 值调整为“更高”(更紧急)的值,这应该导致抛出错误而不是将操作排队等待稍后。
选项 2:尝试添加 longLivedOperationWasPersistedBlock
。如果触发,您可以尝试取消该 block 中的操作,并向用户显示“无网络”错误。
关于ios - 如果由于网络连接不良而尚未完成创建,如何删除 CKRecord?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49095590/
我读到的有关 AdSense 的所有内容都表明我需要一个我确实计划获得的网站(博客、域等)。我只是不确定我想要的域名。 但是,我想继续前进,因为来自 Google 的地址验证信可能需要数周时间。 所以
我有一个支持成就的小游戏。游戏尚未发布,但我需要测试成就。我现在可以做,但只是部分做,例如,当我执行游戏中心应用程序时,它似乎总是在沙盒模式下运行,并且该游戏未在“游戏”选项卡中列出。所以,我看不出成
我有一个 MYSQL 表 1,并希望与表 2 创建一个简单的 UNION: SELECT SomeField FROM Table1 UNION SELECT SomeField FROM Table
我希望我的角色可重用且独立。为了可重用,每个角色都按照“单层抽象”范式进行重点工作。这导致了许多小的“原子”角色,在它们之上构建了多层协调角色以提供更复杂的抽象。 为了自包含,每个角色都应该声明它对其
这个脚本有问题:click here .目前它运行良好。但是,如果我通过 w3 验证器运行它,它就不是“有效的”。我也知道这是为什么,因为整个div都在一个链接内。 我想让这个工作完全一样,但也让它得
前言: 我的核心问题与这个非常相似:How can I write a clean Repository without exposing IQueryable to the rest of my a
我正在测试 Xcode 7 的新 UI 测试功能(在 WWDC 2015 视频“UI Testing in Xcode”中介绍)。 启动时,我的应用通过更新其垂直布局约束的值将“登录面板”设置为动画:
我想在 Rails 服务器上运行 Ruby,但某个 gem 不想安装。这个 rails 程序与 ruby 2.0 不兼容,所以我想使用我安装的 ruby 1.9.3,但是我不能再 bundle
大家好, 我的问题:我想为不存在的 IP 地址启动 (tftp) 服务器。该服务器适用于 USB/RNDIS,其 IP 地址本质上仅在存在实际网络流量时才存在 - 但我想“尽早”启动服务器(例如,当
据我所知,document.getElementById('myId') 只会查找文档中已有的 HTML 元素。假设我通过 JS 创建了一个新元素,但我还没有将它附加到文档主体,是否有一种方法可以像我
我刚刚写了这段代码: // Somewhere earlier, the equivalent of this happens. std::set a; std::set b; FillMeUp(a)
我已阅读 here关于 boost:bind 的工作原理,尤其是它 - 除了其他东西 - 生成如下内容: struct unspecified_type { ... some members ..
假设我的本地存储库当前是原点之后的一个提交。假设我在我的本地存储库中提交了一个与源不冲突的更改。如何在不首先从原点 pull/merge 更改的情况下将此更改推送到原点? 最佳答案 好的,所以你因为非
我这里有一个非常奇怪的问题...我继承了一个相当大的 ASP.NET 3.5 Webforms 元素,一个问题是当启动应用程序时,会显示登录页面 - 但没有任何样式。 ... 这是 Login.asp
我试图从 boost::spirit 规则定义的 Action 中引用一个(尚未)未知实例的成员,所以在伪代码中, 代替 double_[ref(rN) = _1]我正在寻找类似的东西 X** ppx
根据 Cast SDK Docs ,要在我需要的 Android 中使用 Cast SDK,Google Play Services Revision 15。 我在我的 SDK 管理器中没有看到 Re
我是一名优秀的程序员,十分优秀!