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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:56:07+00:00 2026-05-26T14:56:07+00:00

i have a well pre-populated sqlite file that i copied into my project (in

  • 0

i have a well pre-populated sqlite file that i copied into my project (in the folder, and into the xcode project window)

when i check the sqlite file with the Terminal, it works fine, my sqlite file has the right data in it.

But then i try to fill my tableView with the data from the sqlite file, but the tableView is still empty.

Can you please tell me where i should look at?

i first tried with some data and it works (what is commented in applicationDidFinish…), but with my sqlite file, it does not work :

here’s my code : (and here’s the tutorial url : http://www.raywenderlich.com/980/core-data-tutorial-how-to-preloadimport-existing-data)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    NSManagedObjectContext *context = [self managedObjectContext];

    /*
    THIS WORKS :
    FailedBankInfo *failedBankInfo = [NSEntityDescription insertNewObjectForEntityForName:@"FailedBankInfo" 
                                                                   inManagedObjectContext:context];
    failedBankInfo.name = @"the name";
    failedBankInfo.city = @"the city";
    failedBankInfo.state = @"the state";

    FailedBankDetails *failedBankDetails = [NSEntityDescription insertNewObjectForEntityForName:@"FailedBankDetails"
                                                                         inManagedObjectContext:context];

    failedBankDetails.closeDate = [NSDate date];
    failedBankDetails.updatedDate = [NSDate date];
    failedBankDetails.zip = [NSNumber numberWithInt:12345];

    failedBankInfo.details = failedBankDetails;
    failedBankDetails.info = failedBankInfo;

    NSError *error;
    if (![context save:&error]){
        NSLog(@"%@,", [error localizedDescription]);
    }

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"FailedBankInfo" 
                                              inManagedObjectContext:context];
    [fetchRequest setEntity:entity];
    NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
    for (FailedBankInfo *info in fetchedObjects){
        NSLog(@"name : %@", info.name);
        FailedBankDetails *details = info.details;
        NSLog(@"zip : %@", details.zip);
    }
    [fetchRequest release];*/

    FailedBanksListViewController *root = (FailedBanksListViewController *)[_navController topViewController];
    root.context = [self managedObjectContext];
    [window addSubview:_navController.view];

    [self.window makeKeyAndVisible];

    return YES;
}

/** Returns the persistent store coordinator for the application.
 If the coordinator doesn't already exist, it is created and the application's store added to it.
 */
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {

    if (persistentStoreCoordinator_ != nil) {
        return persistentStoreCoordinator_;
    }

    NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"FailedBanksCD.sqlite"];
    /*NSString *storePath = [[self applicationDocumentsDirectory] 
                           stringByAppendingPathComponent: @"FailedBanksCD.sqlite"];
    */
     //NSURL *storeURL = [NSURL fileURLWithPath:storePath];

    // Put down default db if it doesn't already exist
    NSString *storePath = [NSString stringWithFormat:@"%@", storeURL];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    if (![fileManager fileExistsAtPath:storePath]) {
        NSString *defaultStorePath = [[NSBundle mainBundle] 
                                      pathForResource:@"FailedBanksCD" ofType:@"sqlite"];
        if (defaultStorePath) {
            [fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
        }
    }
    NSError *error = nil;
    persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
    if (![persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {

        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }    

    return persistentStoreCoordinator_;
}

Thanks a lot

  • 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-26T14:56:08+00:00Added an answer on May 26, 2026 at 2:56 pm

    To me it looks as if the database was not copied to the doc-dir. Can you move this part

    if (persistentStoreCoordinator_ != nil) {
        return persistentStoreCoordinator_;
    }
    

    beyond this if block:

    if (![fileManager fileExistsAtPath:storePath]) {
        ...
    }
    

    You have to remove the current empty DB from the doc-dir before trying again (remove in simulator, delete app from device and re-install).

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

Sidebar

Related Questions

I currently have a pre-commit hook in my mercurial project that gives the user
Well, i have this thing, i need to edit a XML file that is
Starting a new rails project and we have a well-thought-out color palette, and want
If you want to pre-populate a database (SQLite) in Android, this is not that
I have a simple script that allows someone to download a movie file to
We have a nice pre-commit hook for GIT, as well as a nice commit-msg.
In Java I have code that works well on OSX but not in linux.
I have a mystery.html page that loads some javascript (as well as mootools). I
I'm trying to find the right boost package that comes pre-compiled as well. (For
I have a script that asynchronously loads image src from XML file. The sources

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.