Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8441539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:35:12+00:00 2026-06-10T08:35:12+00:00

I have a method ‘books’ in my view controller that fetches all the books

  • 0

I have a method ‘books’ in my view controller that fetches all the books in core data and returns an array of them. I am relying on self.books often – when I need to know which book it is at certain index, how many books there are, etc, the books method re-fetches the results.

Would I gain any performance improvements by caching these results in an iVar? The vast majority of the time I know that the result of self.books is not going to change (objectAtIndex, count, etc). I could add a second boolean iVar ‘booksNeedRefresh’ to act as a dirty flag, and set it to true only if I add/delete a book. self.books could then check this flag and only re-fetch when necessary.

I guess my questions are:

  1. Does each fetch request from core data introduce a non-negligible performance hit?
  2. Is caching + a dirty flag a sensible solution?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:35:13+00:00Added an answer on June 10, 2026 at 8:35 am

    I think you are on the wrong track. Core Data already provides you with a lot of memory management, so there is not need for “dirty” flags etc.

    The most obvious solution is to use a NSFetchedResultsController. Its main purpose is to display data in a table view while keeping the memory footprint small – but it can be used for other purposes as well. Your books array would become _fetchedResultsController.fetchedObjects, and the FRC will take care of the optimization between memory and fetches.

    To answer your question in principle, the above tradeoff is exactly the issue, so you are correct in thinking about that. Frequent fetches do have performance implications.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I have is data table and I have method in that returns me
I have method that returns Drawable , and if its Bitmap object is recycled
I have method that returns module path of given class name def findModulePath(path, className):
I have method in my N-layered application that returns List<Employee> . Below is the
I have method that parses a list of String records into objects and returns
I have method in my BLL that interacts with the database and retrieves data
I have method which updating data in database from CSV. csv_text = File.read(#{Rails.root}/db/seed/books.csv) csv
I have method that returned NSManagedObject and I don't know what kind of NSManagedObject
I have method in a class that I need to make sure is only
I've got some 3rd party beans that have method signatures that fit quite well

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.