NSFetchedResultsController 初始获取缓慢

发布于 2024-12-14 04:23:41 字数 328 浏览 3 评论 0原文

我正在开发我的第一个核心数据应用程序,并正在使用 NSFetchedResultsController。我的问题是初始提取速度很慢,因此当我的表视图滑入视图时,由于调用初始提取并阻止 UI,因此会出现暂停。在所有示例中,我都看到初始获取是在 viewDidLoad 中完成的。我想知道是否可以在 NSOperation 中完成此操作以避免阻塞主线程?

我不确定如何以线程安全的方式将 NSFetchedResultsController 传递给 NSOperation 。这可能吗?如果不是,如何确保在 FRC 上进行初始获取时 UI 不会被阻塞。

I am working on my first core data app and am working with NSFetchedResultsController. My issue is that the initial fetch is slow, so when my tableview slides into view there is a pause as the initial fetch is called and blocks the UI. In all the examples I have seen the initial fetch is done in viewDidLoad. I was wondering if this can be done in an NSOperation to avoid blocking the main thread?

What I'm not sure about is how to pass the NSFetchedResultsController to to NSOperation in a thread safe way. Is this possible? if not how does one go about ensure that the UI is not blocked when doing the initial fetch on the FRC.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文