A question from the forum: [CoreData] returnsobjectsasfaults What is the use of.
This property is for optimization, but sometimes it degrades performance, and I'll give you a simple analogy, if you have a Department object, it's a one-to-many relationship with the employee object (like a department with 100 employees), and when you load department, All of the employees it contains are also loaded, and if Returnsobjectsasfaults is yes, the employee is not added to the memory, but is placed in the row cache. The employees in the Department object are just a pointer (also known as fault managed object), and the Core data will be read again from the row cache only if you really want to use the employee data in department:
// returnsObjectsAsFaults 为YES// 打印Department对象NSLog(@"%@", department);
See the output:
<Department0x123456 employees : <NSSetdata:fault>>
Otherwise, the employees output you see is a complete list.
The row cache is a cache table, but it can also become large because of too much data, and if you want to traverse all of department's employees (or you're sure you'll be accessing the properties of objects returned through Nsfetchrequest), there's an additional performance overhead. Setting Returnsobjectsasfaults to No will be a better option at this point.
Returnsobjectsasfaults Properties for IOS Core data