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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:16:24+00:00 2026-06-11T00:16:24+00:00

My application is involves users saving data which I store using NSCoding/NSKeyedArchiver. I supply

  • 0

My application is involves users saving data which I store using NSCoding/NSKeyedArchiver. I supply the user with sample data objects on the first run of the app.

The expected behavior happens during regular testing, as well as through ad hoc deployment. Unfortunately, a significant bug happens when the app is downloaded through the app store.

What other environmental considerations might there be so I can reproduce (and then fix) the issue in my regular testing?

Expected behavior:

A new user may add/edit data objects in addition to the current ones. (A classic CRUD scenario).

Actual behavior:

If the user’s first action is to save a new object, all of the previously loaded sample objects disappear (the elusive bug).
However, If the user’s first action is to edit, then all of objects persist as expected, and the user can add additional ones without issue.

Thanks for the help.

EDIT

In my most recent testing, I switched the Build Configuration to release in the “Run ” scheme.

https://i.stack.imgur.com/D01Ix.png

App Delegate, which correctly initializes app

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    self.dataArray = nil;
    self.dataArray = [AppDelegate getArray];
    if (self.dataArray == nil) {
        self.dataArray = [[NSMutableArray alloc] init];
    }

    //First run of the app
    if (dataArray.count == 0) {
        //Add sample data to array
        //Save array
        NSString *path = [AppDelegate getDocPath];
        [NSKeyedArchiver archiveRootObject:self.dataArray toFile:path];
    }
}

+(NSString *) getDocPath {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsPath = [paths objectAtIndex:0];
    NSString *tempDocPath = [documentsPath stringByAppendingPathComponent:@"FilePath.dat"];
    return tempDocPath; 
}

+(NSMutableArray *)getArray {
    return [[NSKeyedUnarchiver unarchiveObjectWithFile:[AppDelegate getDocPath]] mutableCopy];
}

Object creation, which deletes preloaded data if data hasn’t been edited

-(void)viewDidLoad {
    tempArray = nil;
    tempArray = [NSKeyedUnarchiver unarchiveObjectWithFile:[AppDelegate getDocPath]];
    if (tempArray == nil) {
        tempArray = [[NSMutableArray alloc] init];  
    }   
}

-(void)saveObject {
    [tempArray addObject:createdData];
    [tempArray sortUsingSelector:@selector(compare:)];
    NSString *path = [AppDelegate getDocPath];
    [NSKeyedArchiver archiveRootObject:tempArray toFile:path];
    AppDelegate *dg = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    dg.dataArray = tempArray;
}
  • 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-11T00:16:25+00:00Added an answer on June 11, 2026 at 12:16 am

    I guess while saving the new object, you are not appending it to the existing data. You might be over-writing the previously created file. You should access the previous file and append the new data to the previous file. Sharing code would help to point out where you are going wrong.

    EDIT: Replace the following code and check if its still showing the same behaviour

    -(void)viewDidLoad {
        tempArray = nil;
        tempArray = [NSKeyedUnarchiver unarchiveObjectWithFile:[AppDelegate getDocPath]mutableCopy];
        if (tempArray == nil) {
            NSLog(@"tempArray is nil"); //if tempArray doesn't get initialized by the file contents  
            tempArray = [[NSMutableArray alloc] init];
    
        }   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an application which involves so many web-service calls. I am using
I am making a Java desktop application which involves lot of data, state, etc.
I am developing an Azure application, part of which involves users browsing an online
My application involves using submitting data (the request) from a form into an SQL
I am working on an application that involves follow/unfollow functionality. Users can follow Objects
My application (which I am using Visual C# 2008 WinForms for) involves a lot
I'm writing my first Yesod app. The application involves the user selecting to view
Am working on an PHP application that involves multiple plans a user can select.
I'm developing an Android application which involves reading pdf files. Initially on syncing with
I'm creating a phonegap application which involves backbone.js, underscore.js, and require.js I want to

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.