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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:02:21+00:00 2026-05-13T02:02:21+00:00

I have an app that fetches data from the internet and uses CoreData to

  • 0

I have an app that fetches data from the internet and uses CoreData to store them in the device, for a smoother experience.

Because I use Core Data, every time my schema changes, the app crashes when I try to run it with the previous data stored on the device. What is the fastest way to detect this change and wipe all the data from the device, since I don’t mind redownloading them all. It beats crashing and remapping the schema to the new one (in my case).

I see that this check is performed in the getter:

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator

so I only need to know the methodology to implement for wiping the whole database and seting up Core Data again.
Thanks 🙂

  • 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-13T02:02:22+00:00Added an answer on May 13, 2026 at 2:02 am

    Coming back to this question, to delete all the data from my CoreData storage I decided to simple delete the sqlite database file. So I just implemented the NSPersistentStoreCoordinator like this:

    - (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
    
        if (persistentStoreCoordinator != nil) {
            return persistentStoreCoordinator;
        }
    
        NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"myAppName.sqlite"]];
    
        NSError *error = nil;
        persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
        if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) {
    
            NSLog(@"Error opening the database. Deleting the file and trying again.");
    
            //delete the sqlite file and try again
            [[NSFileManager defaultManager] removeItemAtPath:storeUrl.path error:nil];
            if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) {
                NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
                abort();
            }
    
            //if the app did not quit, show the alert to inform the users that the data have been deleted
            UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error encountered while reading the database. Please allow all the data to download again." message:@"" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
            [alert show];
        }
    
        return persistentStoreCoordinator;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an iPhone application that fetches data from internet. I want to
I have a android app that is quite simple it fetches data from the
I have an Android app that fetches data from the web service using ksoap2,
I have an app that fetches data (a list of countries) from an sqlite
I have an app that fetches data from Parse.com and writes it to disk.
I have an app that received JSON data from the server. Currently when I
I have an iOS app that pulls user data down from a web service
I have to store messages that my web app fetch from Twitter into a
I have created an app, that fetchs data from mysql using php. But when
I have an app that pulls data from a server where the timestamp is

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.