Author Topic: Adding the sqlite database file into project  (Read 5202 times)

rtamesis

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Adding the sqlite database file into project
« on: July 30, 2014, 01:49:12 PM »
I'm sure that I missed a step somewhere, but I can't seem to find it. I created a test app using CoreData with a data model called Model, subclassed your mmBusinessObject to aBusinessObject and set its init method to:

- (id)init
{
    self = [super init];
    if (self) {
        self.dbName = @"Model";
        self.copyDatabaseIfNotPresent = YES;
    }
    return self;
}

I populated the Model.sqlite database with test data using FireFox's SQLite tool, and everything works just fine on the simulator. I am able to see the data from the sqlite file on my tableviews just fine. I added a copy of the Model.sqlite file into my Xcode project and tried testing it on my iPad, however, none of my data shows up when I try to run the app on my iPad. What step am my missing?

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Re: Adding the sqlite database file into project
« Reply #1 on: July 30, 2014, 01:55:38 PM »
A few things to check:

1. Select the .sqlite file in the Project Navigator, go to the File Inspector and under the Target Membership section, and if the target isn't checked, check it.
2. Select Product > Clean from the menu
3. Remove the app from your iPad so it gets reinstalled. Sometimes Xcode doesn't update the app properly.

If none of this works, I recommend setting a breakpoint in mmBusinessObject.m persistentStoreCoordinator method and step through the code to see what's happening.

All the best!
Kevin

rtamesis

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
Re: Adding the sqlite database file into project
« Reply #2 on: July 30, 2014, 02:05:01 PM »
Thanks! I did all the steps that you listed, and now it works!

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
Re: Adding the sqlite database file into project
« Reply #3 on: July 30, 2014, 03:58:45 PM »
Glad to help!

Kevin