ReturnsObjectsAsFaults attribute of iOS Core Data, ioscoredata
A question from the Forum: [CoreData] what is returnsObjectsAsFaults used.
This attribute is used for optimization, but sometimes it degrades the performance. For example, if you have a Department object, it has a one-to-multiple relationship with the Employee object (for example, a Department has 100 employees). When you load the Department, all the employees it contains are also loaded, at this time, if returnsObjectsAsFaults is YES, the employees will not be added to the memory, but will be placed in the row cache. The employees in the Department object are just a pointer (also called fault managed object ), core Data is read from the row cache again only when you actually need to use employee Data in the Department:
// ReturnsObjectsAsFaults is YES // print the Department object NSLog (@ "% @", department );
Output:
<Department 0x123456 employees: <NSSet data: fault>
OtherwiseEmployees
The output is a complete list.
Although row cache is a cache table, it may become very large because of too much data, if you want to traverse all employees of the Department (or you are sure that you will access the attributes of the objects returned through NSFetchRequest), there will be additional performance overhead in this case, it is better to set returnsObjectsAsFaults to NO.