Contents

returnsObjectsAsFaults

A Boolean value that indicates whether the objects resulting from a fetch request are faults.

Declaration

var returnsObjectsAsFaults: Bool { get set }

Discussion

This value is true if the objects resulting from a fetch using the NSFetchRequest are faults; otherwise, it is false. The default value is true. This setting is not used if the result type (see resultType) is NSManagedObjectIDResultType, as object IDs do not have property values. You can set returnsObjectsAsFaults to false to gain a performance benefit if you know you will need to access the property values from the returned objects.

When you execute a fetch, by default returnsObjectsAsFaults is true; Core Data fetches the object data for the matching records, fills the row cache with the information, and returns managed object as faults. These faults are managed objects, but all of their property data resides in the row cache until the fault is fired. When the fault is fired, Core Data retrieves the data from the row cache. Although the overhead for this operation is small, for large datasets it may not be trivial. If you need to access the property values from the returned objects (for example, if you iterate over all the objects to calculate the average value of a particular attribute), then it is more efficient to set returnsObjectsAsFaults to false to avoid the additional overhead.

See Also

Managing How Results Are Returned