Skip to content

Commit a8aa455

Browse files
committed
changed README and well documented SQLiteManager class
1 parent 607458b commit a8aa455

File tree

3 files changed

+24
-54
lines changed

3 files changed

+24
-54
lines changed

README

+8-51
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
*************************
66

77
SQLiteManager is a simple Class "wrapper" to use SQLite3 within iOS SDK.
8-
It provides methods to connect/create a database in your documents app folder, do a simple query, get rows and close the connection.
8+
It provides methods to:
9+
- connect/create a database in your documents app folder
10+
- do a simple query
11+
- get rows in NSDictionary format
12+
- close the connection
13+
- dump your data in sql dump format
914

1015
For the moment that's all ;)
1116

12-
SQLiteManager is made by Ester S�nchez (aka misato) and it's free to use, modify and distribute.
17+
SQLiteManager is made by Ester Sanchez (aka misato) and it's free to use, modify and distribute.
1318
If you use it, don't forget to mention me as the original creator.
1419

1520
Thanks and enjoy!
@@ -25,53 +30,5 @@ Just drag the two classes into your project. Also you need to import SQLite3 fra
2530
The code is pretty self-explanatory so i hope you'll understand it.
2631
If you have any doubts, don't hesitate to contact me at esanchez [at] misato [dot] es
2732

28-
An example of the usage could be:
29-
30-
myView.h
31-
---------
32-
33-
@interface myView : UIViewController {
34-
SQLiteManager *dbManager;
35-
}
36-
37-
- (void)insertData;
38-
- (void)getRows;
39-
40-
@end
41-
42-
myView.m
43-
44-
@implementation myView
45-
46-
- (void)viewDidLoad {
47-
//init SQLiteManager
48-
dbManager = [[SQLiteManager alloc] initWithDatabaseNamed:@"myDatabase.db"];
49-
}
50-
51-
//do an insert
52-
- (void)insertData {
53-
NSError *error = [dbManager doQuery: @"insert into myTable (column1, column2) values ('value1','value2');"];
54-
//if an error has occurred
55-
if (error != nil) {
56-
NSLog(@"An error has occurred: %@", [error localizedDescription]);
57-
}
58-
}
59-
60-
// get all data from mytable
61-
- (void)getRows {
62-
63-
NSArray *rowData =[dbManager getRowsForQuery:@"select * from mytable"];
64-
65-
NSLog (@"Row data: %@", rowData);
66-
//do stuff with your data
67-
68-
}
69-
70-
- (void)dealloc {
71-
[super dealloc];
72-
[dbManager release];
73-
}
74-
75-
@end
76-
33+
You have also an usage example in SQLiteManagerExample directory.
7734

SQLiteManager.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ enum errorCodes {
1919
};
2020

2121
@interface SQLiteManager : NSObject {
22-
23-
sqlite3 *db;
24-
NSString *databaseName;
22+
23+
sqlite3 *db; // The SQLite db reference
24+
NSString *databaseName; // The database name
2525
}
2626

2727
- (id)initWithDatabaseNamed:(NSString *)name;

SQLiteManager.m

+13
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ @implementation SQLiteManager
2222

2323
#pragma mark Init & Dealloc
2424

25+
/**
26+
* Init method.
27+
* Use this method to initialise the object, instead of just "init".
28+
*
29+
* @param name the name of the database to manage.
30+
*
31+
* @return the SQLiteManager object initialised.
32+
*/
33+
2534
- (id)initWithDatabaseNamed:(NSString *)name; {
2635
self = [super init];
2736
if (self != nil) {
@@ -31,6 +40,10 @@ - (id)initWithDatabaseNamed:(NSString *)name; {
3140
return self;
3241
}
3342

43+
/**
44+
* Dealloc method.
45+
*/
46+
3447
- (void)dealloc {
3548
[super dealloc];
3649
if (db != nil) {

0 commit comments

Comments
 (0)