NSAttributeDescription Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/CoreData.framework |
| Availability | Available in OS X v10.4 and later. |
| Declared in | NSAttributeDescription.h |
| Companion guides | |
Overview
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.
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.
Tasks
Getting and Setting Type Information
Getting and Setting the Default Value
Versioning Support
Value Transformers
External Binary Storage
Instance Methods
allowsExternalBinaryDataStorage
Returns a Boolean value that indicates whether the attribute allows external binary storage.
Return Value
YES if the attribute allows external binary storage, otherwise NO.
Discussion
If this value is YES, the corresponding attribute may be stored in a file external to the persistent store itself.
Availability
- Available in OS X v10.7 and later.
Declared In
NSAttributeDescription.hattributeType
Returns the type of the receiver.
Return Value
The type of the receiver.
Availability
- Available in OS X v10.4 and later.
Declared In
NSAttributeDescription.hattributeValueClassName
Returns the name of the class used to represent the receiver.
Return Value
The name of the class used to represent the receiver, as a string.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSAttributeDescription.hdefaultValue
Returns the default value of the receiver.
Return Value
The default value of the receiver.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSAttributeDescription.hsetAllowsExternalBinaryDataStorage:
Sets whether the atribute allows
Parameters
- flag
A Boolean value that indicates whether the attribute should allow external binary storage.
Availability
- Available in OS X v10.7 and later.
See Also
Declared In
NSAttributeDescription.hsetAttributeType:
Sets the type of the receiver.
Parameters
- type
An
NSAttributeTypeconstant that specifies the type for the receiver.
Special Considerations
This method raises an exception if the receiver’s model has been used by an object graph manager.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSAttributeDescription.hsetAttributeValueClassName:
Sets the name of the class used to represent the receiver.
Parameters
- className
The name of the class used to represent the receiver.
Discussion
If you set the value class name, Core Data can check the class of any instance set as the value of an attribute.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSAttributeDescription.hsetDefaultValue:
Sets the default value of the receiver.
Parameters
- value
The default value for the receiver.
Discussion
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.
Special Considerations
This method raises an exception if the receiver’s model has been used by an object graph manager.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSAttributeDescription.hsetValueTransformerName:
Sets the name of the transformer to use to transform the attribute value.
Parameters
- string
The name of the transformer to use to transform the attribute value. The transformer must output an
NSDataobject fromtransformedValue:and must allow reverse transformations.
Discussion
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.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSAttributeDescription.hvalueTransformerName
Returns the name of the transformer used to transform the attribute value.
Return Value
The name of the transformer used to transform the attribute value.
Discussion
The receiver must be an attribute of type NSTransformedAttributeType.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSAttributeDescription.hversionHash
Returns the version hash for the receiver.
Return Value
The version hash for the receiver.
Discussion
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.
Availability
- Available in OS X v10.5 and later.
See Also
-
versionHash(NSPropertyDescription)
Declared In
NSAttributeDescription.hConstants
NSAttributeType
Defines 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;
Constants
NSUndefinedAttributeTypeSpecifies an undefined attribute type.
NSUndefinedAttributeTypeis valid for transient properties—Core Data will still track the property as anidvalue and register undo/redo actions, and so on.NSUndefinedAttributeTypeis illegal for non-transient properties.Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSInteger16AttributeTypeSpecifies a 16-bit signed integer attribute.
Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSInteger32AttributeTypeSpecifies a 32-bit signed integer attribute.
Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSInteger64AttributeTypeSpecifies a 64-bit signed integer attribute.
Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSDecimalAttributeTypeSpecifies an
NSDecimalNumberattribute.Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSDoubleAttributeTypeSpecifies a double attribute.
Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSFloatAttributeTypeSpecifies a float attribute.
Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSStringAttributeTypeSpecifies an
NSStringattribute.Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSBooleanAttributeTypeSpecifies a Boolean attribute.
Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSDateAttributeTypeSpecifies an
NSDateattribute.Times are specified in GMT.
Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSBinaryDataAttributeTypeSpecifies an
NSDataattribute.Available in OS X v10.4 and later.
Declared in
NSAttributeDescription.h.NSTransformableAttributeTypeSpecifies an attribute that uses a value transformer.
Available in OS X v10.5 and later.
Declared in
NSAttributeDescription.h.NSObjectIDAttributeTypeSpecifies the object ID attribute.
Available in OS X v10.6 and later.
Declared in
NSAttributeDescription.h.
Availability
- Available in OS X v10.4 and later.
Declared In
NSAttributeDescription.h© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-12-28)