Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading 10k+ rows in iphone SQLite (FMDB)
    primarykey
    data
    text
    <p>I am creating a dictionary app and I am trying to load the terms into an iphone dictionary for use. The terms are defined from this table (<a href="http://www.sqlite.org/" rel="nofollow">SQLite</a>):</p> <pre><code>id -&gt; INTEGER autoincrement PK termtext -&gt; TEXT langid -&gt; INT normalized -&gt; TEXT </code></pre> <p>Normalized is used because I am writing in GREEK and I don't have icu on the sqlite engine for searching diacritics, so I am making a termtext diacritics/case insensitive. It is also the main search field, in contrast of termtext which could be the "view" field.</p> <p>I have defined an class (like a POJO) like this:</p> <p><b>terms.h</b></p> <pre><code>#import &lt;Foundation/Foundation.h&gt; @interface Terms : NSObject { NSUInteger termId; // id NSString* termText; // termtext NSUInteger langId; // langid NSString* normalized; // normalized } @property (nonatomic, copy, readwrite) NSString* termText; @property (nonatomic, copy, readwrite) NSString* normalized; @property (assign, readwrite) NSUInteger termId; @property (assign, readwrite) NSUInteger langId; @end </code></pre> <p><b>terms.c</b></p> <pre><code>#import "Terms.h" @implementation Term @synthesize termId; @synthesize termText; @synthesize langId; @synthesize normalized; @end </code></pre> <p>Now in my code I use <a href="https://github.com/ccgus/fmdb" rel="nofollow">FMDB</a> as the wrapper for the <a href="http://www.sqlite.org/" rel="nofollow">SQLite</a> database. I load the terms using the following code:</p> <pre><code>[... fmdb defined database as object, opened ] NSMutableArray *termResults = [[[NSMutableArray alloc] init] autorelease]; FMResultSet *s = [database executeSQL:@"SELECT id, termtext, langid, normalized FROM terms ORDER BY normalized ASC"]; while ([s next]) { Term* term = [[Terms alloc] init]; term.termId = [s intForColumn:@"id"]; [... other definitions] [termResults addObject:term]; [term release]; } </code></pre> <p>The whole termResults is then loaded to a <a href="http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UITableView_Class/Reference/Reference.html" rel="nofollow">UITableView</a> (on viewdidload) but the loading takes up to 5 seconds every time I start my app. Is there any way to speedup that process? I have indexed id, termText and normalized on <a href="http://www.sqlite.org/" rel="nofollow">SQLite</a>.</p> <p><strong>* UPDATE: added cellForRowAtIndexPath **</strong></p> <pre><code>[.. standard cell definition...] // Configure the cell Term* termObj = [self.termResults objectAtIndex:indexPath.row]; cell.textLabel.text = termObj.termText; return cell; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload