Quantcast
Channel: Core Data – Michael Tsai
Viewing all articles
Browse latest Browse all 217

Zarra’s Core Data Stack

$
0
0

Marcus Zarra creates a private queue context for writing to disk and a main queue (child) context for all user interaction:

To protect our main thread, we call -addPersistentStoreWithType: configuration: URL: options: error: in a dispatched background block. This will allow our -initializeCoreData method to return immediately, even if the persistent store needs to do some additional work. However, the user interface needs to know when it is safe to access the persistence layer. Therefore we need to use the callback block that was given to us.

[…]

The proper way to get access to the persistence controller is to inject it into each view controller as they are built and accessed.

[…]

The occasions where I don’t use this stack usually involve large data manipulation. When I need to process a tremendous amount of data into the Core Data stack and that data can be isolated away from the User Interface.


Viewing all articles
Browse latest Browse all 217

Trending Articles