<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSMergeConflict",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMergeConflict"
  },
  "title" : "NSMergeConflict"
}
-->

# NSMergeConflict

An encapsulation of conflicts that occur during an attempt to save changes in a managed object context.

```
class NSMergeConflict
```

## Overview

A conflict can occur in two situations:

- Between the managed object context and its in-memory cached state at the persistent store coordinator layer.
- Between the cached state at the persistent store coordinator layer and the external store (file, database, and so forth). 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.

## Topics

### Initializing a Merge Conflict

[`-  initWithSource:newVersion:oldVersion:cachedSnapshot:persistedSnapshot:`](/documentation/CoreData/NSMergeConflict/init(source:newVersion:oldVersion:cachedSnapshot:persistedSnapshot:))

Initializes a merge conflict.

### Accessing Merge Conflict Details

[`sourceObject`](/documentation/CoreData/NSMergeConflict/sourceObject)

The source object for the conflict.

[`objectSnapshot`](/documentation/CoreData/NSMergeConflict/objectSnapshot)

A dictionary containing the values of the source object.

[`cachedSnapshot`](/documentation/CoreData/NSMergeConflict/cachedSnapshot)

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

[`persistedSnapshot`](/documentation/CoreData/NSMergeConflict/persistedSnapshot)

A dictionary containing the values of the source object held in the persistent store.

[`newVersionNumber`](/documentation/CoreData/NSMergeConflict/newVersionNumber)

The new version number for the change.

[`oldVersionNumber`](/documentation/CoreData/NSMergeConflict/oldVersionNumber)

The old version number for the change.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)