Returnsobjectsasfaults Properties for IOS Core data

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.