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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:19:10+00:00 2026-06-13T09:19:10+00:00

I am working with a core database, it is working in IOS 6 but

  • 0

I am working with a core database, it is working in IOS 6 but when I trying to test it on IOS 5. It does not do anything. Let me explain what I’m doing.

First I do this in my viewWillAppear.

- (void)viewWillAppear:(BOOL)animated
{
    NSLog(@"view appeared");
    [super viewWillAppear:animated];
    if (!self.genkDatabase) {
        NSLog(@"comes to here");
        NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
        url = [url URLByAppendingPathComponent:@"Default appGenk Database2"];
        // url is now "<Documents Directory>/Default Photo Database"
        self.genkDatabase = [[UIManagedDocument alloc] initWithFileURL:url]; // setter will create this for us on disk
        NSLog(@"database created on disk");
    }

}

Then it comes in the UseDocument method.

- (void)useDocument
{
    NSLog(@"Comses in the use document");
    if (![[NSFileManager defaultManager] fileExistsAtPath:[self.genkDatabase.fileURL path]]) {
        // does not exist on disk, so create it
        [self.genkDatabase saveToURL:self.genkDatabase.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
            NSLog(@"create");
            [self setupFetchedResultsController];
           [self fetchGenkDataIntoDocument:self.genkDatabase];

        }];
    } else if (self.genkDatabase.documentState == UIDocumentStateClosed) {
        NSLog(@"closed news");
        // exists on disk, but we need to open it
        [self.genkDatabase openWithCompletionHandler:^(BOOL success) {
            [self setupFetchedResultsController];
        }];
    } else if (self.genkDatabase.documentState == UIDocumentStateNormal) {
        NSLog(@"normal");
        // already open and ready to use
        [self setupFetchedResultsController];
    }

}

And finally it goes into the setDatabase Method.

- (void)setGenkDatabase:(UIManagedDocument *)genkDatabase
{
    if (_genkDatabase != genkDatabase) {
        _genkDatabase = genkDatabase;
        [self useDocument];
    }
    NSLog(@"Comes in the setdatabase methode.");
}

Doing all this gives the following log.

2012-10-22 10:42:47.444 RacingGenk[4786:c07] view appeared
2012-10-22 10:42:47.445 RacingGenk[4786:c07] comes to here
2012-10-22 10:42:47.459 RacingGenk[4786:c07] Comses in the use document
2012-10-22 10:42:47.460 RacingGenk[4786:c07] Comes in the setdatabase methode.
2012-10-22 10:42:47.461 RacingGenk[4786:c07] database created on disk

Like you can see it does not print the create log in my use document. So it isn’t able to execute the method FetchDataIntoDocument.

Can anybody help me with this problem. I am searching at this problem for ages for now.

Many thanks in advace.

Stef

  • 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-13T09:19:11+00:00Added an answer on June 13, 2026 at 9:19 am

    Are you testing with the simulator or on the device?
    The simulator is case-insensitive – the device is case-sensitive on file access, remember that!

    But beside from that the documentation for NSFileManager recommends not checking to see if files exist, and instead just trying to read the file and handle any errors gracefully (e.g. file not found error). So just try loading the file instead of checking to see if it exists.

    And i don’t see any file extension for your database file! It just states “”Default appGenk Database2”.
    Is this already the file name or jut another subdirectory so far?

    EDIT:

    You can try the following code:

    - (void) setupStore {
        NSString* storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"mydatabase.sqlite"];
    
        // Set up the store.
        NSFileManager* fileManager = [NSFileManager defaultManager];
        // If the expected store doesn't exist, create one.
        if (![fileManager fileExistsAtPath: storePath]) {
            // create your store here!
        }
    }
    
    
    - (NSString*) applicationDocumentsDirectory {
        return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    }
    

    “mydatabase.sqlite” is the name of the database-file you expect to be present in your documents directory.

    If you would like to see a full-fledged example on how to set-up a core data persistent store you could check out apples own iPhoneCoreDataRecipes example. Just take a look at the

    RecipesAppDelegate.m

    implementation.

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

Sidebar

Related Questions

This is working fine in core php, but not in magento. $party_payment = new
I am working on this core data app, and im not exactly shure how
I am working on a database application using the Core Data framework. In this
This is on iOS. I have a Core Database with about 350 000 objects.
I'm trying to accelerate this database search application with CUDA, and I'm working on
I'm working on an iOS app. I have a Core Data database with a
im working with core-data for the first time, and my app is handling a
I'm working on my first Core Data project (on iPhone) and am really liking
I am working with a core database to save my data that I get
I'm trying to use the spring-security-core database request map config and it doesn't seem

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.