Contents

NSDerivedAttributeDescription

A description of an attribute that derives its value by performing a calculation on a related attribute.

Declaration

class NSDerivedAttributeDescription

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. [Image] Supported functions include canonical:, uppercase:, and lowercase:. [Image] 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. [Image] Supported functions include @count and @sum.

friends.@count

time

The current time.

now()

Topics

Specifying the Derivation Expression

See Also

Computed attributes