ReturnsObjectsAsFaults attribute of iOS Core Data, ioscoredata

Source: Internet
Author: User

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>

OtherwiseEmployeesThe 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.

Related Article

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.