---
title: NSConstraintConflict
framework: coredata
role: symbol
role_heading: Class
path: coredata/nsconstraintconflict
---

# NSConstraintConflict

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

## Declaration

```swift
class NSConstraintConflict
```

## Overview

Overview A constraint conflict occurs when your data model is using unique constraints and one or more managed objects are violating that constraint. When this error occurs, the error instance can be interrogated to determine which instance of NSManagedObject is violating the constraint and which property on the NSManagedObject instance is in violation.

## Topics

### Initializing a Conflict

- [init(constraint:database:databaseSnapshot:conflicting:conflictingSnapshots:)](coredata/nsconstraintconflict/init(constraint:database:databasesnapshot:conflicting:conflictingsnapshots:).md)

### Inspecting a Conflict

- [conflictingObjects](coredata/nsconstraintconflict/conflictingobjects.md)
- [conflictingSnapshots](coredata/nsconstraintconflict/conflictingsnapshots.md)
- [constraint](coredata/nsconstraintconflict/constraint.md)
- [constraintValues](coredata/nsconstraintconflict/constraintvalues.md)
- [databaseObject](coredata/nsconstraintconflict/databaseobject.md)
- [databaseSnapshot](coredata/nsconstraintconflict/databasesnapshot.md)

### Initializers

- [init(constraint:databaseObject:databaseSnapshot:conflictingObjects:conflictingSnapshots:)](coredata/nsconstraintconflict/init(constraint:databaseobject:databasesnapshot:conflictingobjects:conflictingsnapshots:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Conflict Management

- [NSMergeConflict](coredata/nsmergeconflict.md)
- [NSMergePolicy](coredata/nsmergepolicy.md)
- [NSQueryGenerationToken](coredata/nsquerygenerationtoken.md)
