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 6742687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:52:23+00:00 2026-05-26T11:52:23+00:00

My app uses Core Data and has an attribute called ‘beenSeen’. When a user

  • 0

My app uses Core Data and has an attribute called ‘beenSeen’. When a user refreshes the app, all ‘beenSeen’ values of 1 are changed to 0. On an iPod Touch 2nd gen with over 2000 objects, refreshing takes over a minute. My code looks like this:

    for (Deck *deck in self.deckArray) {
        if ([deck.beenSeen isEqualToNumber:[NSNumber numberWithInt:1]]) {
            [deck setBeenSeen:[NSNumber numberWithInt:0]];
            [self.managedObjectContext save:&error];           
        }
    }

I’m also considering deleting the sqlite file and having an alert ask the user to restart the app themselves. Doing that sure is a whole lot quicker than what I have now. Is there a quicker way to refresh an entity? Could I have a ‘backup’ entity and copy it over? Thanks for any help.

  • 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-05-26T11:52:24+00:00Added an answer on May 26, 2026 at 11:52 am

    Hm. The first optimization I’d suggest would be

    for (Deck *deck in self.deckArray) {
        if ([deck.beenSeen isEqualToNumber:[NSNumber numberWithInt:1]]) {
            [deck setBeenSeen:[NSNumber numberWithInt:0]];
        }
    }
    [self.managedObjectContext save:&error];           
    

    I suspect it might speed things up to do one big context save, instead of 2,000 little ones.

    The second suggestion would be to try getting rid of the if test – if the majority of your beenSeen values are changing from 1 to 0, and the others are already 0, then you might as well just set all of them to 0 and save the time of checking each one individually. (On the other hand, if there are 10,000 objects and you’re resetting 2,000 of them, then getting rid of the test might not be optimal.)

    for (Deck *deck in self.deckArray) {
        [deck setBeenSeen:[NSNumber numberWithInt:0]];
        }
        [self.managedObjectContext save:&error];           
    }
    

    The third suggestion would be to think about implementing this another way – for instance, your deck object could implement a lastSeen attribute, storing the date and time when the deck was last seen, and then instead of doing a mass reset (and writing 2,000 Core Data rows) you could just test each deck’s lastSeen date and time against the timestamp of the last user refresh.

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

Sidebar

Related Questions

I am writing an iPhone app which uses core data for storage. All of
I want to build an app that uses core data, but all the tutorials
I'm developing a Core Data app that uses a model object called Location. The
I have an app that uses core data. The app is free for download
I have an iphone app that uses Core Data to do storage. I have
I am working on an app that uses Core Data as its backend for
Environment: xcode 3.2.1, document-based core-data application. I have a document-based cocoa app which uses
We have an app that uses Core Data. In the next version I would
I am creating an app which uses Core Data. I have a flip-side in
I'm working on an iPhone app that uses Core Data. The app makes a

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.