iPhone SDK: loading UITableView from SQLite

Posted by leon on Stack Overflow See other posts from Stack Overflow or by leon
Published on 2009-10-12T06:00:09Z Indexed on 2010/04/29 3:17 UTC
Read the original article Hit count: 414

Filed under:
|
|
|

Hi, I think I got a good handle on UITableViews and on getting/inserting data from/to SQLite db. I am straggling with an architectural question.

My application saves 3 values int the database, there can be many/many rows. However would I load them in the table?

From all the tutorials I have seen, at one point entire database is loaded in the NSMutableArray or similar object via performing SELECT statement.

Then when

-(UITableViewCell *) tableView: (UITableView *) tableView cellForRowAtIndexPath: (NSIndexPath *) indexPath

called, rows required are dolled out from the previous loaded NSMutableArray (or similar stracture).

But what i have have thousands for rows? Why would I pre-load them?

Should I just query database each time cellForRowAtIndexPath is called? If so, what would I use as an index?

Each row in the table will have an AUTOINCREMENT index, but since some rows may be deleted index will not correspond to rows in the table (in the SQL I may have something like this with row with index 3 missing):

1 Data1 Data1 2 Data2 Data2 4. data3 data3

Thanks

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uitableview