Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 400373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:56:08+00:00 2026-05-12T16:56:08+00:00

I think I got a good handle on UITableViews and on getting/inserting data from/to

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:56:09+00:00Added an answer on May 12, 2026 at 4:56 pm

    I solve this by reading what the table cell needs from my db into the datasource array, of all the existing db entries. The objects don’t get removed from the array however, they stay there unless they need to be removed.

    For example one of my apps reads 1’700 rows, for each row creates an object, assigns an NSUInteger (the autoincrement value) and an NSString (the name of the object, which will be displayed in the cell) and puts them into the datasource array. This whole process takes only about 200-300 milliseconds – you’ll have to test whether it takes too long for 10’000+ entries, but for some thousand entries it sould be okay to just read it all. I remember that memory consumption is also quite low, can’t look up how much exactly ATM.

    Then, when the user taps a row, I query the datasource array to find the object he just tapped, and this object then loads all its other values from the database, which it can do since it knows its own database key/id (it “hydrates” itself).

    For completeness sake (using FMDB):

    NSResultSet *res = [db executeQuery:@"SELECT my_key, my_name FROM table"];
    while ([res next]) {
        NSDictionary *dict = [res resultDict];
        MyObj *obj = [MyObj obj];
        obj.id = [dict objectForKey:@"my_key"];
        obj.name = [dict objectForKey:@"my_name"];
    
        [datasourceArray addObject:obj];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got what I think is a simple question. I've seen examples both ways.
I'm starting a project which I think would benefit from bindings (I've got a
I think I've got it down to the most basic case: int main(int argc,
I'm trying to design a database for a sports meeting. I think I've got
I've got an ssl certificate for what I think is my domain and I
I've got a lot of pages in my site, I'm trying to think of
I've got a strange problem with SQL Server 2000, and I just can't think
I've got a name of a method: Garden.Plugins.Code.Beta.Business.CalculateRest How to run it? I think
I think this should be easy, but it's evading me. I've got a many-to-many
Hi im making a custom Textbox i got everty thing working but how do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.