I read the SQLITE3 example and the AppDelegate is used to open the SQLite datbase and it is also used to initiate all database activity.
However, in my application , I have multiple view controllers and depending on user input , all of the view controllers would like to modify or read the database.
My question is...how do you share an sqlite3* object between view controllers? In the SQLITE3 example they declare
sqlite3* database
in the AppDelegate and they assign to "database" using a C function call and passing it "&database". Then , AppDelegate
opens the database.
So how do my other view controllers get access to this?If I have a different view controller, I thought that I could put code in the AwakeFromNib that could message the AppDelegate for the database pointer. Then, I could assign the result to a local sqlite3* database variable in my view controller .Would that work? Is that necessary? Am I missing something simple? How do you make database queries from multiple view controllers without having to use the AppDelegate as the central point of control?
However, in my application , I have multiple view controllers and depending on user input , all of the view controllers would like to modify or read the database.
My question is...how do you share an sqlite3* object between view controllers? In the SQLITE3 example they declare
sqlite3* database
in the AppDelegate and they assign to "database" using a C function call and passing it "&database". Then , AppDelegate
opens the database.
So how do my other view controllers get access to this?If I have a different view controller, I thought that I could put code in the AwakeFromNib that could message the AppDelegate for the database pointer. Then, I could assign the result to a local sqlite3* database variable in my view controller .Would that work? Is that necessary? Am I missing something simple? How do you make database queries from multiple view controllers without having to use the AppDelegate as the central point of control?