Mac Developer Library

Developer

CoreData Framework Reference NSMergeConflict Class Reference

Options
Deployment Target:

On This Page
Language:

NSMergeConflict

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.

Inheritance


Conforms To


Import Statement


Swift

import CoreData

Objective-C

@import CoreData;

Availability


Available in OS X v10.7 and later.
  • Initializes a merge conflict.

    Declaration

    Swift

    init(source srcObject: NSManagedObject, newVersion newvers: Int, oldVersion oldvers: Int, cachedSnapshot cachesnap: [NSObject : AnyObject], persistedSnapshot persnap: [NSObject : AnyObject]?)

    Objective-C

    - (instancetype)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.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var sourceObject: NSManagedObject { get }

    Objective-C

    @property(readonly, retain) NSManagedObject *sourceObject

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var objectSnapshot: [NSObject : AnyObject]? { get }

    Objective-C

    @property(readonly, retain) NSDictionary *objectSnapshot

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var cachedSnapshot: [NSObject : AnyObject] { get }

    Objective-C

    @property(readonly, retain) NSDictionary *cachedSnapshot

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var persistedSnapshot: [NSObject : AnyObject]? { get }

    Objective-C

    @property(readonly, retain) NSDictionary *persistedSnapshot

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var newVersionNumber: Int { get }

    Objective-C

    @property(readonly) NSUInteger newVersionNumber

    Discussion

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

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in OS X v10.7 and later.

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

    Declaration

    Swift

    var oldVersionNumber: Int { get }

    Objective-C

    @property(readonly) NSUInteger oldVersionNumber

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in OS X v10.7 and later.