Popular Tags

Who's online

There are currently 0 users and 123 guests online.

User login

Matteo Bertozzi has written a simple SQLite Wrapper with examples for Mac and for the iPhone. The wrapper class has the same source code for both platforms. On the same page you can also find example code for Mac and the iPhone.

Below is a simple example of how to use it:

Sqlite *sqlite = [[Sqlite alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
                             NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory
if (![sqlite open:writableDBPath])
[sqlite executeNonQuery:@"CREATE TABLE test (key TEXT NOT NULL, value TEXT);"];
[sqlite executeNonQuery:@"DELETE FROM test;"];
[sqlite executeNonQuery:@"INSERT INTO test VALUES (?, ?);",
                        [Sqlite createUuid], @"PROVA"];
[sqlite executeNonQuery:@"INSERT INTO test VALUES (?, ?);",
                         [Sqlite createUuid], @"PROVA 2"];
[sqlite executeNonQuery:@"INSERT INTO test VALUES (?, ?);",
                         [Sqlite createUuid], @"PROVA 3"];
NSArray *results = [sqlite executeQuery:@"SELECT * FROM test;"];
for (NSDictionary *dictionary in results) {
  for (NSString *key in [dictionary keyEnumerator])
      NSLog(@" - %@ %@", key, [dictionary objectForKey:key]);
[results release];
[sqlite release];

Your rating: None Average: 3 (1 vote)



The site has recently been updated. You may notice some of the following issues:

  • Some URLs no longer work. Please use the search box.
  • File uploads should now be working. If you experience problems, please contact us.