NSMergeConflict Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/CoreData.framework
Availability
Available in OS X v10.7 and later.
Companion guide
Declared in
NSMergePolicy.h

Overview

A merge conflict encapsulates conflicts that occur when attempting to save changes in a managed object context.

There are two situations in which a conflict may occur:

  1. Between the managed object context and its in-memory cached state at the persistent store coordinator layer.

    In this case, the merge conflict has a source object and a cached snapshot but no persisted snapshot.

  2. Between the cached state at the persistent store coordinator and the external store (file, database, etc.).

    In this case, the merge conflict has a cached snapshot and a persisted snapshot. The source object is also provided as a convenience, but it is not directly involved in the conflict.

Snapshot dictionaries include values for all attributes and to-one relationships, but not to-many relationships. Relationship values are NSManagedObjectID references. To-many relationships must be pulled from the persistent store as needed.

Tasks

Initializing a Merge Conflict

Properties

cachedSnapshot

A dictionary containing the values of the source object held in the persistent store coordinator layer. (read-only)

@property(readonly, retain) NSDictionary *cachedSnapshot
Availability
  • Available in OS X v10.7 and later.
Declared In
NSMergePolicy.h

newVersionNumber

The new version number for the change. (read-only)

@property(readonly) NSUInteger newVersionNumber
Discussion

A new version number of 0 means the object was deleted and the corresponding snapshot is nil.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSMergePolicy.h

objectSnapshot

A dictionary containing the values of the source object. (read-only)

@property(readonly, retain) NSDictionary *objectSnapshot
Availability
  • Available in OS X v10.7 and later.
Declared In
NSMergePolicy.h

oldVersionNumber

The old version number for the change. (read-only)

@property(readonly) NSUInteger oldVersionNumber
Availability
  • Available in OS X v10.7 and later.
Declared In
NSMergePolicy.h

persistedSnapshot

A dictionary containing the values of the source object held in the persistent store. (read-only)

@property(readonly, retain) NSDictionary *persistedSnapshot
Availability
  • Available in OS X v10.7 and later.
Declared In
NSMergePolicy.h

sourceObject

The source object for the conflict. (read-only)

@property(readonly, retain) NSManagedObject *sourceObject
Availability
  • Available in OS X v10.7 and later.
Declared In
NSMergePolicy.h

Instance Methods

initWithSource:newVersion:oldVersion:cachedSnapshot:persistedSnapshot:

Initializes a merge conflict.

- (id)initWithSource:(NSManagedObject *)srcObject newVersion:(NSUInteger)newvers oldVersion:(NSUInteger)oldvers cachedSnapshot:(NSDictionary *)cachesnap persistedSnapshot:(NSDictionary *)persnap
Parameters
srcObject

The source object for the conflict.

newvers

The new version number for the change.

A value of 0 means the object was deleted and the corresponding snapshot is nil.

oldvers

The old version number for the change.

cachesnap

A dictionary containing the values of srcObject held in the persistent store coordinator layer.

persnap

A dictionary containing the values of srcObject held in the persistent store.

Return Value

A merge conflict object initialized with the given parameters.

Availability
  • Available in OS X v10.7 and later.
Declared In
NSMergePolicy.h