Permalink
Browse files

changed README and well documented SQLiteManager class

  • Loading branch information...
misato committed Mar 10, 2011
1 parent 607458b commit a8aa455ec35d249da605f51976a6d58c3b418e6e
Showing with 24 additions and 54 deletions.
  1. +8 −51 README
  2. +3 −3 SQLiteManager.h
  3. +13 −0 SQLiteManager.m
View
59 README
@@ -5,11 +5,16 @@
*************************
SQLiteManager is a simple Class "wrapper" to use SQLite3 within iOS SDK.
-It provides methods to connect/create a database in your documents app folder, do a simple query, get rows and close the connection.
+It provides methods to:
+- connect/create a database in your documents app folder
+- do a simple query
+- get rows in NSDictionary format
+- close the connection
+- dump your data in sql dump format
For the moment that's all ;)
-SQLiteManager is made by Ester S�nchez (aka misato) and it's free to use, modify and distribute.
+SQLiteManager is made by Ester Sanchez (aka misato) and it's free to use, modify and distribute.
If you use it, don't forget to mention me as the original creator.
Thanks and enjoy!
@@ -25,53 +30,5 @@ Just drag the two classes into your project. Also you need to import SQLite3 fra
The code is pretty self-explanatory so i hope you'll understand it.
If you have any doubts, don't hesitate to contact me at esanchez [at] misato [dot] es
-An example of the usage could be:
-
-myView.h
----------
-
-@interface myView : UIViewController {
- SQLiteManager *dbManager;
-}
-
-- (void)insertData;
-- (void)getRows;
-
-@end
-
-myView.m
-
-@implementation myView
-
-- (void)viewDidLoad {
- //init SQLiteManager
- dbManager = [[SQLiteManager alloc] initWithDatabaseNamed:@"myDatabase.db"];
-}
-
-//do an insert
-- (void)insertData {
- NSError *error = [dbManager doQuery: @"insert into myTable (column1, column2) values ('value1','value2');"];
- //if an error has occurred
- if (error != nil) {
- NSLog(@"An error has occurred: %@", [error localizedDescription]);
- }
-}
-
-// get all data from mytable
-- (void)getRows {
-
- NSArray *rowData =[dbManager getRowsForQuery:@"select * from mytable"];
-
- NSLog (@"Row data: %@", rowData);
- //do stuff with your data
-
-}
-
-- (void)dealloc {
- [super dealloc];
- [dbManager release];
-}
-
-@end
-
+You have also an usage example in SQLiteManagerExample directory.
View
@@ -19,9 +19,9 @@ enum errorCodes {
};
@interface SQLiteManager : NSObject {
-
- sqlite3 *db;
- NSString *databaseName;
+
+ sqlite3 *db; // The SQLite db reference
+ NSString *databaseName; // The database name
}
- (id)initWithDatabaseNamed:(NSString *)name;
View
@@ -22,6 +22,15 @@ @implementation SQLiteManager
#pragma mark Init & Dealloc
+/**
+ * Init method.
+ * Use this method to initialise the object, instead of just "init".
+ *
+ * @param name the name of the database to manage.
+ *
+ * @return the SQLiteManager object initialised.
+ */
+
- (id)initWithDatabaseNamed:(NSString *)name; {
self = [super init];
if (self != nil) {
@@ -31,6 +40,10 @@ - (id)initWithDatabaseNamed:(NSString *)name; {
return self;
}
+/**
+ * Dealloc method.
+ */
+
- (void)dealloc {
[super dealloc];
if (db != nil) {

0 comments on commit a8aa455

Please sign in to comment.