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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:47:16+00:00 2026-05-26T08:47:16+00:00

Clearly I must not be doing something right but this happens on random occasions.

  • 0

Clearly I must not be doing something right but this happens on random occasions. I can’t make the issue appear by following certain steps so it has become extremely hard to debug. I have an app in which every time an object is added, or deleted it writes the file to a plist. I can verify the plist in the simulator and I also have an NSLog each time my save function is called. The data is loaded when applicationWillEnterForeground is called, which is also working correctly. On certain occasions after starting up the app it will revert to the previous save before the most recent changes. Does iOS cache data files? If it tries to load a file from disk to an array, could it possible already have the previous load in a cache and create the array with that data instead?

Save method:

- (void)saveFile {
    // saves data to file

    NSLog(@"save file reached");
#ifdef LITE_VERSION

    [self.aquariums writeToFile:[self dataFilePathLite] atomically:YES];

#else

    [self.aquariums writeToFile:[self dataFilePath] atomically:YES];

#endif
}

Load method; I just added the if (self.aquariums == null) check and it might have solved the issue but it’s hard for me to confirm since I can’t recreate the problem:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */

    NSLog(@"applicationDidBecomeActive called");

if (self.aquariums == NULL) {
    NSLog(@"aquariums null, loading file");

    #ifdef LITE_VERSION
        NSString *filePath = [self dataFilePathLite];
    #else
        NSString *filePath = [self dataFilePath];
    #endif

        if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
            NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:filePath];
            self.aquariums = array;
            [array release];

            [self update21];

        } else {

    #ifdef LITE_VERSION
            [self convertFileName];

    #else
            [self update20];
    #endif
        }

        application.applicationIconBadgeNumber = 0;

        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
            aquaPlannerAppDelegate_iPad *appDelegate = [[UIApplication sharedApplication] delegate];
            [appDelegate.rootView viewDidAppear:YES];
        }
}
}
  • 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-26T08:47:17+00:00Added an answer on May 26, 2026 at 8:47 am

    After releasing and not getting any reports of loss of data the issue must definitely have been

    if (self.aquariums == NULL) {
    

    so people remember if you are going to reload data when an app returns from being in the background set it to null first and release

    aquariums = NULL;
    [aquariums release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is clearly not appears like it wouldn't be a best practice. Can someone
Edit : I must not have worded it clearly enough, but I'm looking for
I hope I can explain this clearly enough. I have my main form (A)
I'm surprised that I could not find any info on this. I must be
I feel like I must be missing something, but I just don't see what
Clearly, when GROUP BY clause used, columns that are not aggregate function should be
How can we clearly differ architectural term abstraction from a software component, can abstraction
How can you clearly illustrate multiple threads of execution in a sequence diagram or
I'm clearly a newb, and I was wondering if anyone knows how I can
Can someone clearly explain me how these functions of heap sort are working?? void

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.