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 8623277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:14:38+00:00 2026-06-12T07:14:38+00:00

I am trying to use SQLite to hold data for my app. This database

  • 0

I am trying to use SQLite to hold data for my app. This database could have thousands of records in, so loading them all into an array on startup probably isn’t a good idea. So I load them each individually in cellForForAtIndexPath by id. This works, but I can’t sort them… Can anybody think of a better way? I bet it’s really simple :L

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"VerbCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    VerbData *verb = [[VerbData alloc] init];
    if(isFiltered)
        verb = [searchResults objectAtIndex:indexPath.row];
    else
    {
        const char *sql = [[NSString stringWithFormat: @"SELECT infinitive, english FROM verbs WHERE id=%d", indexPath.row+1] UTF8String];
        sqlite3_stmt *sqlStatement;
        if(sqlite3_prepare_v2(db, sql, -1, &sqlStatement, NULL) != SQLITE_OK){
            NSLog(@"Problem with prepare statement: %s", sqlite3_errmsg(db));
        }else{
            while (sqlite3_step(sqlStatement) == SQLITE_ROW) {
                verb.infinitive = [NSString stringWithUTF8String:(char *)sqlite3_column_text(sqlStatement,0)];
                verb.english = [NSString stringWithUTF8String:(char *)sqlite3_column_text(sqlStatement,1)];
            }
        }
    }

    cell.textLabel.text = verb.infinitive;
    cell.detailTextLabel.text = verb.english;

    return cell;
}

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-06-12T07:14:39+00:00Added an answer on June 12, 2026 at 7:14 am

    You can select in order using offset and limit

    Row Offset in SQL Server

    Belkadmin is right, when you use ORDER BY [ ASCENDING | DESCENDING ] all sorting job will be made by DBMS which is good for mobile if you have remote database, so server side woll do all hard work. You can also use

    SELECT … FROM … ORDER BY …OFFSET LIMIT

    where:
    offset – is offset from the beginning of database
    limit – is the maximum amount of data rows gathered by query

    You can then load your table in chunks. Other trick is to query for rows asynchronously as the table scrolls i.e. load first 100 rows but when user is below 70th row another query is made asynchronously and adds data to datasource array

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use an SQLite database to store some data for my app.
I'm trying to use sqlite as database for a symbian app but I can't
I'm trying to use an in-memory SQLite database to test my data layer which
This is my first try to use SQLite, I am trying to retrieve data
I'm trying to use System.Data.Sqlite library, and I'm following the documentation about optimizing inserts
I'm trying to use Induction to connect to my local SQLite database however I've
I have been trying to use the hibernate dialect for SQLite from http://code.google.com/p/hibernate-sqlite/ in
I'm trying to use sqlite in a 'data services' class like below. I keep
Im trying to use an sqlite database in xcode 4.2 and ios5 sdk. The
I have a last probleme before finishing my application. I use SQLITE DataBase. Everything

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.