An Objective-C database abstraction framework.
DatabaseKit is an unbelievably straight-forward to use database framework for Objective-C.
DBConnection
.// Open a SQLite database
DB *db = [DB withURL:[NSURL URLWithString:@"sqlite://myDb.sqlite"]];
if(err)
NSLog(@"Couldn't open database: %@.", [err localizedDescription]);
// Get the names of every person in our database
DBTable *people = db[@"people"];
DBSelectQuery *names = [people select:@"name"];
for(NSDictionary *row in [names limit:100]) {
NSLog(@"Name: %@", row[@"name"]);
}
// Delete really old people
[[[people delete] where:@"bornOn < %@", [NSDate distantPast]] execute];
// Change the name of everyone called John
[[[people update:@{ @"name": @"Percie" }] where:@"name = %@", @"John"] execute];
// You can create a class to represent results from a table like so:
// (Our project's class prefix is `NICE`)
@interface NICEPerson : DBModel
@property(readwrite, retain) NSString *name, *address;
- (void)introduceYourself;
@end
@implementation NICEPerson
- (void)introduceYourself
{
NSLog(@"Hi! I'm %@.", self.name);
}
@end
// And now if you perform a query
NicePerson *someone = [[people select] firstObject];
[someone introduceYourself];