Skip to content

usage best practice

NickTrienens edited this page Sep 13, 2010 · 1 revision

I’m writing a listing app, basically a few list of 2 different object types with detail/edit screens. usually when I do this I make a singleton to handle most, if not all of my database interaction, this can be great since the singleton has a variable for the path to the db file and i don’t have to include the database headers in most of my viewcontrollers. Currently i open and close the database for each query/update that is done. I’m not threading any database interactions, since I just store user input, so I’m wondering if there is any downside to just leaving the database open as an instance var on the singleton possibly cutting down load time of data. My main concern is when is data actually store on the disk, from what I’ve seen and read about sqlite the file is only changed on disk when it is closed, not sure if i want to leave that all important task for the applicationWillTerminate method(what with crashes, phone calls and notifications).

Just wondering what you recommend for being sure to get your data saved.

Clone this wiki locally