iOS Developer Library

Developer

CoreData Framework Reference NSPropertyDescription Class Reference

Options
Deployment Target:

On This Page
Language:

NSPropertyDescription

Conforms To


Import Statement


Swift

import CoreData

Objective-C

@import CoreData;

Availability


Available in iOS 3.0 and later.

The NSPropertyDescription class is used to define properties of an entity in a Core Data managed object model. Properties are to entities what instance variables are to classes.

A property describes a single value within an object managed by the Core Data Framework. There are different types of property, each represented by a subclass which encapsulates the specific property behavior—see NSAttributeDescription, NSRelationshipDescription, and NSFetchedPropertyDescription.

Note that a property name cannot be the same as any no-parameter method name of NSObject or NSManagedObject. For example, you cannot give a property the name "description". There are hundreds of methods on NSObject which may conflict with property names—and this list can grow without warning from frameworks or other libraries. You should avoid very general words (like "font”, and “color”) and words or phrases which overlap with Cocoa paradigms (such as “isEditing” and “objectSpecifier”).

Properties—relationships as well as attributes—may be transient. A managed object context knows about transient properties and tracks changes made to them. Transient properties are ignored by the persistent store, and not just during saves: you cannot fetch using a predicate based on transients (although you can use transient properties to filter in memory yourself).

Editing Property Descriptions

Property descriptions are editable until they are used by an object graph manager (such as a persistent store coordinator). 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.

  • entity entity Property

    The entity description of the receiver. (read-only)

    Declaration

    Swift

    unowned(unsafe) var entity: NSEntityDescription { get }

    Objective-C

    @property(nonatomic, readonly, assign) NSEntityDescription *entity

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

    See Also

    setProperties: (NSEntityDescription)

  • indexed indexed Property

    A Boolean value that indicates whether the receiver should be indexed for searching.

    Declaration

    Swift

    var indexed: Bool

    Objective-C

    @property(getter=isIndexed) BOOL indexed

    Discussion

    YEStrue if the receiver should be indexed for searching, otherwise NOfalse. Object stores can optionally use this information upon store creation for operations such as defining indexes.

    Special Considerations

    Setting this property raises an exception if the receiver’s model has been used by an object graph manager.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • optional optional Property

    A Boolean value that indicates whether the receiver is optional.

    Declaration

    Swift

    var optional: Bool

    Objective-C

    @property(getter=isOptional) BOOL optional

    Discussion

    YEStrue if the receiver is optional, otherwise NOfalse. The optionality flag specifies whether a property’s value can be nil before an object can be saved to a persistent store.

    Special Considerations

    Setting this property raises an exception if the receiver’s model has been used by an object graph manager.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 8.0 and later.

  • transient transient Property

    A Boolean value that indicates whether the receiver is transient.

    Declaration

    Swift

    var transient: Bool

    Objective-C

    @property(getter=isTransient) BOOL transient

    Discussion

    YEStrue if the receiver is transient, otherwise NOfalse. The transient flag specifies whether or not a property’s value is ignored when an object is saved to a persistent store. Transient properties are not saved to the persistent store, but are still managed for undo, redo, validation, and so on.

    Special Considerations

    Setting this property raises an exception if the receiver’s model has been used by an object graph manager.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 8.0 and later.

  • name name Property

    The name of the receiver.

    Declaration

    Swift

    var name: String

    Objective-C

    @property(nonatomic, copy) NSString *name

    Discussion

    A property name cannot be the same as any no-parameter method name of NSObject or NSManagedObject. Since there are hundreds of methods on NSObject which may conflict with property names, you should avoid very general words (like "font”, and “color”) and words or phrases that overlap with Cocoa paradigms (such as “isEditing” and “objectSpecifier”).

    Special Considerations

    Setting the name raises an exception if the receiver’s model has been used by an object graph manager.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • userInfo userInfo Property

    The user info dictionary of the receiver.

    Declaration

    Swift

    var userInfo: [NSObject : AnyObject]?

    Objective-C

    @property(nonatomic, strong) NSDictionary *userInfo

    Special Considerations

    Setting the user info raises an exception if the receiver’s model has been used by an object graph manager.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • The validation predicates of the receiver. (read-only)

    Declaration

    Swift

    var validationPredicates: [AnyObject] { get }

    Objective-C

    @property(readonly, strong) NSArray *validationPredicates

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • The error strings associated with the receiver’s validation predicates. (read-only)

    Declaration

    Swift

    var validationWarnings: [AnyObject] { get }

    Objective-C

    @property(readonly, strong) NSArray *validationWarnings

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • Sets the validation predicates and warnings of the receiver.

    Declaration

    Swift

    func setValidationPredicates(_ validationPredicates: [AnyObject]?, withValidationWarnings validationWarnings: [AnyObject]?)

    Objective-C

    - (void)setValidationPredicates:(NSArray *)validationPredicates withValidationWarnings:(NSArray *)validationWarnings

    Parameters

    validationPredicates

    An array containing the validation predicates for the receiver.

    validationWarnings

    An array containing the validation warnings for the receiver.

    Discussion

    The validationPredicates and validationWarnings arrays should contain the same number of elements, and corresponding elements should appear at the same index in each array.

    Instead of implementing individual validation methods, you can use this method to provide a list of predicates that are evaluated against the managed objects and a list of corresponding error messages (which can be localized).

    Special Considerations

    This method raises an exception if the receiver’s model has been used by an object graph manager.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • The version hash for the receiver. (read-only)

    Declaration

    Swift

    @NSCopying var versionHash: NSData { get }

    Objective-C

    @property(readonly, copy) NSData *versionHash

    Discussion

    The version hash is used to uniquely identify a property based on its configuration. The version hash uses only values which affect the persistence of data and the user-defined versionHashModifier value. (The values which affect persistence are the name of the property, and the flags for isOptional, isTransient, and isReadOnly.) This value is stored as part of the version information in the metadata for stores, as well as a definition of a property involved in an NSPropertyMapping object.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • The version hash modifier for the receiver.

    Declaration

    Swift

    var versionHashModifier: String?

    Objective-C

    @property(copy) NSString *versionHashModifier

    Discussion

    This value is included in the version hash for the property. You use it to mark or denote a property as being a different “version” than another even if all of the values which affect persistence are equal. (Such a difference is important in cases where the attributes of a property are unchanged but the format or content of its data are changed.)

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

    See Also

    – versionHash

  • The renaming identifier for the receiver.

    Declaration

    Swift

    var renamingIdentifier: String?

    Objective-C

    @property(copy) NSString *renamingIdentifier

    Discussion

    This is used to resolve naming conflicts between models. When creating an entity mapping between entities in two managed object models, a source entity property and a destination entity property that share the same identifier indicate that a property mapping should be configured to migrate from the source to the destination. If unset, the identifier will return the property's name.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • A Boolean value that indicates whether the property should be indexed by Spotlight.

    Declaration

    Swift

    var indexedBySpotlight: Bool

    Objective-C

    @property(getter=isIndexedBySpotlight) BOOL indexedBySpotlight

    Discussion

    YEStrue if the property should be indexed by Spotlight, otherwise NOfalse. For additional information, see Core Data Spotlight Integration Programming Guide.

    Special Considerations

    This property has no effect on iOS.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.

  • A Boolean value that indicates whether the property data should be written out in an external record file corresponding to the managed object.

    Declaration

    Swift

    var storedInExternalRecord: Bool

    Objective-C

    @property(getter=isStoredInExternalRecord) BOOL storedInExternalRecord

    Discussion

    YEStrue if the property data should be written out in an external record file corresponding to the managed object, otherwise NOfalse. For additional information, see Core Data Spotlight Integration Programming Guide.

    Special Considerations

    This property has no effect on iOS.

    Import Statement

    Objective-C

    @import CoreData;

    Swift

    import CoreData

    Availability

    Available in iOS 3.0 and later.