Manually:
- Add
Database
folder to your project. - Add
libsqlite3.tbd
orlibsqlite3.0.tbd
to Project -> General -> Linked Frameworks and Libraries. - Import
DBManager.h
to AppDelegate and call below method in didFinishLaunchingWithOptions.
[DBManager copyDatabaseIfNeeded];
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
[data setObject:@"Yash" forKey:@"Name"];
[data setObject:@"yashthaker7@gmail.com" forKey:@"Email"];
[DBManager createTable:@"Users" withDictionary:data]; // pass dictionary and table name.
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
[data setObject:@"Yash" forKey:@"Name"];
[data setObject:@"yashthaker7@gmail.com" forKey:@"Email"];
[DBManager insertData:data tableName:@"Users"]; // pass dictionary and table name.
NSArray *user = [[NSArray alloc] initWithArray:[DBManager findDataWithId:2 tableName:@"Users"]]; // pass id and table name.
NSString *query = [NSString stringWithFormat:@"select * from Users"];
NSArray *user = [[NSArray alloc] initWithArray:[DBManager findDataWithQuery:query]]; // pass query.
NSArray *users = [[NSArray alloc] initWithArray:[DBManager getAllData:@"Users"]]; // pass table name.
BOOL delete = [DBManager deleteDataWithId:1 tableName:@"Users"]; // pass id and table name.
NSMutableDictionary *updateData = [[NSMutableDictionary alloc] init];
[updateData setObject:@"update" forKey:@"Name"];
[updateData setObject:@"update@gmail.com" forKey:@"Email"];
[DBManager updateData:updateData id:1 tableName:@"Users"]; // pass dictionary, id and table name.
NSString *getPath = [DBManager getDBPath];