Processing core data operations under multi-threading

Source: Internet
Author: User

Note: This article is written, there are better ways to produce it.

Note: You can use Threads (nsthread), GCD, or operationqueue to operate.

Using thread confinement to support concurrency

Each thread must have its own managed object context. Here are two possible modes.

1. Each thread creates a managed object context, sharing a persistent store coordinator. This is the recommended mode.

2. Each thread has a separate Manged object context, and persistent store coordinator.

This mode of expenditure is relatively large

If you are using Operationqueue, create a context inside the main or Start method.

If thread is closed, managed objects or managed object contexts cannot be passed between threads.

If you let it create a context between threads, it will go beyond the bounds of the thread.

-Find object by Objectid

-Perform a fetch to find the context

This allows you to find the local version of the managed object in the local context.

You can use Nsfetchrequest to provide a way to traverse threads more easily.

Processing core data operations under multi-threading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.