Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Link to <code>libsqlite3.dylib</code> (and import <code>&lt;sqlite3.h&gt;</code>) to access the power of SQLite. There are a number of lightweight Objective-C front ends and I suggest you pick one. In this example, I use <code>fmdb</code> (https://github.com/ccgus/fmdb) to read the names of people out of a previously created database:</p> <pre><code>NSString* docsdir = [NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; NSString* dbpath = [docsdir stringByAppendingPathComponent:@"people.db"]; FMDatabase* db = [FMDatabase databaseWithPath:dbpath]; if (![db open]) { NSLog(@"Ooops"); return; } FMResultSet *rs = [db executeQuery:@"select * from people"]; while ([rs next]) { NSLog(@"%@ %@", [rs stringForColumn:@"firstname"], [rs stringForColumn:@"lastname"]); } [db close]; /* output: Snidely Whiplash Dudley Doright */ </code></pre> <p>That illustrates talking to the database; knowing SQL is up to you (and is a different topic). You can include a previously constructed SQLite file in your app bundle, but you can't write to it there; the solution is to copy it from your app bundle into another location, such as the Documents directory, before you start working with it.</p> <p>Finally, to put strings into text fields (UITextField), set their <code>text</code> property. So for example instead of the <code>while</code> loop shown above, where I log the database results, I could use those results to set text field values:</p> <pre><code>myTextField.text = [rs stringForColumn:@"firstname"]; myOtherTextField.text = [rs stringForColumn:@"lastname"]; </code></pre>
    singulars
    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.
    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