Link to multiple sqlite tables on iPhone?
I am missing "Stack Overflow fu", but we found a previous answer.
One of my applications has its data in a SQLite database and I used the Apple SQLiteBooks sample as my main inspiration, however SQLiteBooks only has one table and one view. I have multiple (linked) tables available as separate views in the tab bar - eg. Cookbooks, recipes, ingredients, utensils, etc. Some problems with the example code:
1) The example code seems to be initialized too early (at applicationDidFinishLaunching: when I lean towards viewDidLoad :)
2) Static SQL query strings should be different for each class (on the other hand, they usually differ only in the table being accessed, so I can use "?" On the static string and then bind the table id as needed?)
3) If I follow the TheElements sample code, which uses plists as the data store, I seem to be wasting too much time and memory "pre-building" the data sources of not still viewed tabs.
Does anyone have any pointers to best practices as to how / where to define multiple instances of the same class from a sample while still maintaining high performance and low memory?
source to share
Can't you use? to bind table names, only the values in the query.
I suggest you take a look at FMDB , which is a SQLite wrapper in Objective-C.
With this, you can easily make different objects query the databases (a kind of ORM at home).
There are several ActiveRecord implementations in Objective-C that you can take a look at, but I haven't used them.
source to share