| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/CoreData.framework |
| Availability | Available in Mac OS X v10.4 and later. |
| Declared in | NSAttributeDescription.h |
| Companion guides | |
| Related sample code |
The NSAttributeDescription class is used to describe 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.
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.
Returns the type of the receiver.
- (NSAttributeType)attributeType
The type of the receiver.
NSAttributeDescription.hReturns the name of the class used to represent the receiver.
- (NSString *)attributeValueClassName
The name of the class used to represent the receiver, as a string.
NSAttributeDescription.hReturns the default value of the receiver.
- (id)defaultValue
The default value of the receiver.
NSAttributeDescription.hSets the type of the receiver.
- (void)setAttributeType:(NSAttributeType)type
An NSAttributeType constant that specifies the type for the receiver.
This method raises an exception if the receiver’s model has been used by an object graph manager.
NSAttributeDescription.hSets the name of the class used to represent the receiver.
- (void)setAttributeValueClassName:(NSString *)className
The name of the class used to represent the receiver.
If you set the value class name, Core Data can check the class of any instance set as the value of an attribute.
NSAttributeDescription.hSets the default value of the receiver.
- (void)setDefaultValue:(id)value
The default value for the receiver.
Default values are retained by a managed object model, not copied. This means that attribute values do not have to implement the NSCopying protocol, however it also means that you should not modify any objects after they have been set as default values.
This method raises an exception if the receiver’s model has been used by an object graph manager.
NSAttributeDescription.hSets the name of the transformer to use to transform the attribute value.
- (void)setValueTransformerName:(NSString *)string
The name of the transformer to use to transform the attribute value. The transformer must output an NSData object from transformedValue: and must allow reverse transformations.
The receiver must be an attribute of type NSTransformedAttributeType.
If this value is not set, or is set to nil, Core Data will default to using a transformer which uses NSCoding to archive and unarchive the attribute value.
NSAttributeDescription.hReturns the name of the transformer used to transform the attribute value.
- (NSString *)valueTransformerName
The name of the transformer used to transform the attribute value.
The receiver must be an attribute of type NSTransformedAttributeType.
NSAttributeDescription.hReturns the version hash for the receiver.
- (NSData *)versionHash
The version hash for the receiver.
The version hash is used to uniquely identify an attribute based on its configuration. This value includes the versionHash information from NSPropertyDescription and the attribute type.
– versionHash (NSPropertyDescription)NSAttributeDescription.hDefines the possible types of NSAttributeType properties. These explicitly distinguish between bit sizes to ensure data store independence.
typedef enum {
NSUndefinedAttributeType = 0,
NSInteger16AttributeType = 100,
NSInteger32AttributeType = 200,
NSInteger64AttributeType = 300,
NSDecimalAttributeType = 400,
NSDoubleAttributeType = 500,
NSFloatAttributeType = 600,
NSStringAttributeType = 700,
NSBooleanAttributeType = 800,
NSDateAttributeType = 900,
NSBinaryDataAttributeType = 1000,
NSTransformableAttributeType = 1800,
NSObjectIDAttributeType = 2000
} NSAttributeType;
NSUndefinedAttributeTypeSpecifies an undefined attribute type.
NSUndefinedAttributeType is valid for transient properties—Core Data will still track the property as an id value and register undo/redo actions, and so on. NSUndefinedAttributeType is illegal for non-transient properties.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSInteger16AttributeTypeSpecifies a 16-bit signed integer attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSInteger32AttributeTypeSpecifies a 32-bit signed integer attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSInteger64AttributeTypeSpecifies a 64-bit signed integer attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSDecimalAttributeTypeSpecifies an NSDecimalNumber attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSDoubleAttributeTypeSpecifies a double attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSFloatAttributeTypeSpecifies a float attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSStringAttributeTypeSpecifies an NSString attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSBooleanAttributeTypeSpecifies a Boolean attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSDateAttributeTypeSpecifies an NSDate attribute.
Times are specified in GMT.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSBinaryDataAttributeTypeSpecifies an NSData attribute.
Available in Mac OS X v10.4 and later.
Declared in NSAttributeDescription.h.
NSTransformableAttributeTypeSpecifies an attribute that uses a value transformer.
Available in Mac OS X v10.5 and later.
Declared in NSAttributeDescription.h.
NSObjectIDAttributeTypeSpecifies the object ID attribute.
Available in Mac OS X v10.6 and later.
Declared in NSAttributeDescription.h.
NSAttributeDescription.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-05-01)