table search an sqlite3 database

Discussion in 'iOS Programming' started by mekopolis, Oct 9, 2008.

  1. mekopolis macrumors regular

    Feb 10, 2008
  2. fenrus110 macrumors regular

    Mar 24, 2008
    why don't you just query the sql table, then put the values into an NSArray?
  3. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    It depends on the data. In essence you have to build an array that represents the data in the database even though the array won't be full. However, you don't have to load all the data into memory. If you have a small number of rows, say less than 1000, then I'd probably just load it into an array. If you have a large number of rows then you want to pre-sort it in some way.

    My array is an array of dictionaries where each dictionary holds an array that represents the actual rows of the table. Each dictionary represents a section of the table.

    I have a tableview that lists people 'Lastname, firstname' where the records are stored in a db. I pre-sort the rows and store counts for the number of records that have a last name that starts with each letter of the alphabet. So I have 26 records each with a count for a letter. So I know how many rows in the table. When the user types the first letter into the search box I retrieve all of the records where the first letter of the last name matches that letter. So I'm only retrieving a fraction of the records, but that's what will be visible to the user.
  4. mekopolis thread starter macrumors regular

    Feb 10, 2008
    thanks for your responses

    def. interesting ways to approach it

    i have about 500 entries into a sqlite3 database

    for sorting, i was considering having a sort by name, state, etc, and each button would execute a ORDER BY command that would sort the entries

    but with so many entries, a real time table search would be more practical

    so if i was to load the table, lets say the name into an NSArray, i would have to load all 500+ just to be able to have the user do a real time table search for a name?

Share This Page