Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
iPhone example code demonstrating Core Data multi-threading
Objective-C C
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Classes
MultiThreadedCoreData.xcdatamodeld
MultiThreadedCoreData.xcodeproj
.gitignore
MainWindow.xib
MultiThreadedCoreData-Info.plist
MultiThreadedCoreData_Prefix.pch
Person.h
Person.m
README.md
RootViewController.xib
main.m

README.md

Overview

This is a sample App to demonstrate Core Data multi-threading for safe updates

The application seeds itself with a Core Data entity and then provides a button to run 2 operations. The NSOperations:

  • update different fields of the same entity
  • take a different amount of time to run (intended to simulate distinct differences caused by networking)
  • attempt to save their changes.

The UI allows one to alter the merge policies that are applied to the NSManagedObjectContext used by the application main thread and by the NSOperations. By looking at the console, you can see which combination of merge policies will work best for your application.

It seems as though the merge policy on the main thread NSManagedObjectContext has no bearing on the outcome of the merge; only the merge policy on the NSManagedObjectContext that performed some changes has any effect.

For usages where different operations update different fields, it is suggested that NSMergeByPropertyObjectTrumpMergePolicy would be a good option. For other usages, one would need to balance up the requirements of the application and consider ways of partitioning updates.

Something went wrong with that request. Please try again.