Justin
Justin

Reputation: 248

Where to place sqlite3_open code for ios

On first view that is displayed to the user, I have to populate some text fields with some saved information on the phone.

Does apple have a diagram for the entire state of app-launchign sequence? Ie, that includes the app delegate method calls and the view delegate method calls? It seems that order of events switch for different iOS versions...

For example: http://oleb.net/blog/2011/06/app-launch-sequence-ios/ Lets say you had a custom view controller in MainWindow.xib, won't viewWillAppear be called before didFinishLaunchingWithOptions?

To be safe, should I just wrap a quick call around all my sqlite3 database functions that check if the database is open before continuing, and open it if necessary?

Upvotes: 0

Views: 265

Answers (1)

erran
erran

Reputation: 1320

I used an SQL Database in an iPhone application that put opened the database if it was closed inside a void called from viewDidLoad. It wasn't detrimental at all to the performance of the application. Though in a newer app I needed to grab some preferences (not in an SQL Database this time) as the application opened so I created an instance of my ViewController and called it's reload preferences method from the App Delegate's -(void)applicationDidBecomeActive:(UIApplication *)application; method (Reruns the method every time my app becomes active) like so:

- (void)applicationDidBecomeActive:(UIApplication *)application{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
ViewController *instanceOfVC = [[[ViewController alloc] init]autorelease];
[instanceOfVC checkPreferences];
}

Upvotes: 1

Related Questions