A description of the attributes of an entity described by an instance of NSEntityDescription.


NSAttributeDescription inherits from NSPropertyDescription, which provides most of the basic behavior. Instances of NSAttributeDescription are used to describe attributes, as distinct from relationships. The class adds the ability to specify the attribute type, and to specify a default value. In a managed object model, you must specify the type of all attributes—you can only use the undefined attribute type (NSUndefinedAttributeType) for transient attributes.

Editing Attribute Descriptions

Attribute descriptions are editable until they are used by an object graph manager. This allows you to create or modify them dynamically. However, once a description is used (when the managed object model to which it belongs is associated with a persistent store coordinator), it must not (indeed cannot) be changed. This is enforced at runtime: any attempt to mutate a model or any of its sub-objects after the model is associated with a persistent store coordinator causes an exception to be thrown. If you need to modify a model that is in use, create a copy, modify the copy, and then discard the objects with the old model.


Getting and Setting Type Information

var attributeType: NSAttributeType

The type of the attribute.

var attributeValueClassName: String?

The name of the class used to represent the attribute.

Getting and Setting the Default Value

var defaultValue: Any?

The default value of the attribute.

Supporting Versioning

var versionHash: Data

The version hash for the attribute.

Transforming the Attribute Value

var valueTransformerName: String?

The name of the transformer used to transform the attribute value.

Specifying External Binary Storage

var allowsExternalBinaryDataStorage: Bool

A Boolean value that indicates whether the attribute allows external binary storage.

Defining Attribute Types

enum NSAttributeType

Defines the possible types of NSAttributeType properties. These explicitly distinguish between bit sizes to ensure data store independence.


See Also

Inspecting Entities and Configurations

var entities: [NSEntityDescription]

The entities in the model.

var entitiesByName: [String : NSEntityDescription]

The entities of the model, keyed by name.

var configurations: [String]

All the available configuration names of the model.

func entities(forConfigurationName: String?)

Returns the entities of the model for a specified configuration.

func setEntities([NSEntityDescription], forConfigurationName: String)

Associates the specified entities with the model using the given configuration name.

class NSEntityDescription

A description of an entity in Core Data.

class NSManagedObjectID

A compact, universal identifier for a managed object.

class NSPropertyDescription

A description of the properties of an entity in a Core Data managed object model.

class NSRelationshipDescription

A description of the relationships of an entity in an NSEntityDescription object.