0

What do I need to set up the database in my ios project? I know I have to make a copy of the database file but do I need to rewrite the same setup code in each view controller where I plan to actually retrieve and save data?

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDir = [documentPaths objectAtIndex:0];
self.databasePath = [documentDir stringByAppendingPathComponent:@"gameDefault.sqlite"];

[self createAndCheckDatabase];

I have this in my appdelegate, but do I need to have the same code in my facebook view controller where I plan to save user info?

Jim Chen
  • 157
  • 1
  • 3
  • 11

1 Answers1

0

Use a single instance of FMDB, initialised with the path, across your app and view controllers. FMDB will create the DB for you if it doesn't exist.

rounak
  • 9,217
  • 3
  • 42
  • 59