Class

NSDerivedAttributeDescription

A description of an attribute of a Core Data entity that derives its value from one or more other properties.

Declaration

class NSDerivedAttributeDescription : NSAttributeDescription

Overview

Use derived attributes to optimize fetch performance; for example:

  • Create a derived searchName attribute to reflect a name attribute with case and diacritics removed for more efficient comparison.

  • Create a derived relationshipCount attribute to reflect the number of objects in a relationship and avoid having to do a join.

Derived attributes support the following expressions:

Expression

Description

Example

to-one keypath

A single value to replicate.

name or author.name

to-one keypath with a function

The result of calling a function on a single value.

Supported functions include canonical:, uppercase:, and lowercase:.

The canonical: function returns a case- and diacritic-insensitive String value.

canonical:(name)

to-many keypath with a function

The result of calling an aggregate function on a set of values.

Supported functions include @count and @sum.

friends.@count

time

The current time.

now()

Topics

Specifying the Derivation Expression

var derivationExpression: NSExpression?

An expression for generating derived data.

Relationships

Conforms To

See Also

Attributes and Relationships

class NSPropertyDescription

A description of a property of a Core Data entity.

class NSAttributeDescription

A description of an attribute of a Core Data entity.

enum NSAttributeType

The possible types of Core Data attributes.

class NSRelationshipDescription

A description of a relationship of a Core Data entity.