diff --git a/.gitignore b/.gitignore
index 8ebcf91..e798235 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,6 @@ local.properties
node_modules/
npm-debug.log
-Pods/
+#Pods/
diff --git a/ios/Pods/FMDB/LICENSE.txt b/ios/Pods/FMDB/LICENSE.txt
new file mode 100644
index 0000000..addfc1a
--- /dev/null
+++ b/ios/Pods/FMDB/LICENSE.txt
@@ -0,0 +1,28 @@
+If you are using FMDB in your project, I'd love to hear about it. Let Gus know
+by sending an email to gus@flyingmeat.com.
+
+And if you happen to come across either Gus Mueller or Rob Ryan in a bar, you
+might consider purchasing a drink of their choosing if FMDB has been useful to
+you.
+
+Finally, and shortly, this is the MIT License.
+
+Copyright (c) 2008-2014 Flying Meat Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/ios/Pods/FMDB/README.markdown b/ios/Pods/FMDB/README.markdown
new file mode 100644
index 0000000..f4d7c3d
--- /dev/null
+++ b/ios/Pods/FMDB/README.markdown
@@ -0,0 +1,397 @@
+# FMDB v2.6
+
+This is an Objective-C wrapper around SQLite: http://sqlite.org/
+
+## The FMDB Mailing List:
+http://groups.google.com/group/fmdb
+
+## Read the SQLite FAQ:
+http://www.sqlite.org/faq.html
+
+Since FMDB is built on top of SQLite, you're going to want to read this page top to bottom at least once. And while you're there, make sure to bookmark the SQLite Documentation page: http://www.sqlite.org/docs.html
+
+## Contributing
+Do you have an awesome idea that deserves to be in FMDB? You might consider pinging ccgus first to make sure he hasn't already ruled it out for some reason. Otherwise pull requests are great, and make sure you stick to the local coding conventions. However, please be patient and if you haven't heard anything from ccgus for a week or more, you might want to send a note asking what's up.
+
+## CocoaPods
+
+[](https://www.versioneye.com/objective-c/fmdb/2.3)
+[](https://www.versioneye.com/objective-c/fmdb/references)
+
+FMDB can be installed using [CocoaPods](https://cocoapods.org/).
+
+```
+pod 'FMDB'
+# pod 'FMDB/FTS' # FMDB with FTS
+# pod 'FMDB/standalone' # FMDB with latest SQLite amalgamation source
+# pod 'FMDB/standalone/FTS' # FMDB with latest SQLite amalgamation source and FTS
+# pod 'FMDB/SQLCipher' # FMDB with SQLCipher
+```
+
+**If using FMDB with [SQLCipher](https://www.zetetic.net/sqlcipher/) you must use the FMDB/SQLCipher subspec. The FMDB/SQLCipher subspec declares SQLCipher as a dependency, allowing FMDB to be compiled with the `-DSQLITE_HAS_CODEC` flag.**
+
+## FMDB Class Reference:
+http://ccgus.github.io/fmdb/html/index.html
+
+## Automatic Reference Counting (ARC) or Manual Memory Management?
+You can use either style in your Cocoa project. FMDB will figure out which you are using at compile time and do the right thing.
+
+## Usage
+There are three main classes in FMDB:
+
+1. `FMDatabase` - Represents a single SQLite database. Used for executing SQL statements.
+2. `FMResultSet` - Represents the results of executing a query on an `FMDatabase`.
+3. `FMDatabaseQueue` - If you're wanting to perform queries and updates on multiple threads, you'll want to use this class. It's described in the "Thread Safety" section below.
+
+### Database Creation
+An `FMDatabase` is created with a path to a SQLite database file. This path can be one of these three:
+
+1. A file system path. The file does not have to exist on disk. If it does not exist, it is created for you.
+2. An empty string (`@""`). An empty database is created at a temporary location. This database is deleted with the `FMDatabase` connection is closed.
+3. `NULL`. An in-memory database is created. This database will be destroyed with the `FMDatabase` connection is closed.
+
+(For more information on temporary and in-memory databases, read the sqlite documentation on the subject: http://www.sqlite.org/inmemorydb.html)
+
+```objc
+FMDatabase *db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];
+```
+
+### Opening
+
+Before you can interact with the database, it must be opened. Opening fails if there are insufficient resources or permissions to open and/or create the database.
+
+```objc
+if (![db open]) {
+ [db release];
+ return;
+}
+```
+
+### Executing Updates
+
+Any sort of SQL statement which is not a `SELECT` statement qualifies as an update. This includes `CREATE`, `UPDATE`, `INSERT`, `ALTER`, `COMMIT`, `BEGIN`, `DETACH`, `DELETE`, `DROP`, `END`, `EXPLAIN`, `VACUUM`, and `REPLACE` statements (plus many more). Basically, if your SQL statement does not begin with `SELECT`, it is an update statement.
+
+Executing updates returns a single value, a `BOOL`. A return value of `YES` means the update was successfully executed, and a return value of `NO` means that some error was encountered. You may invoke the `-lastErrorMessage` and `-lastErrorCode` methods to retrieve more information.
+
+### Executing Queries
+
+A `SELECT` statement is a query and is executed via one of the `-executeQuery...` methods.
+
+Executing queries returns an `FMResultSet` object if successful, and `nil` upon failure. You should use the `-lastErrorMessage` and `-lastErrorCode` methods to determine why a query failed.
+
+In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" from one record to the other. With FMDB, the easiest way to do that is like this:
+
+```objc
+FMResultSet *s = [db executeQuery:@"SELECT * FROM myTable"];
+while ([s next]) {
+ //retrieve values for each record
+}
+```
+
+You must always invoke `-[FMResultSet next]` before attempting to access the values returned in a query, even if you're only expecting one:
+
+```objc
+FMResultSet *s = [db executeQuery:@"SELECT COUNT(*) FROM myTable"];
+if ([s next]) {
+ int totalCount = [s intForColumnIndex:0];
+}
+```
+
+`FMResultSet` has many methods to retrieve data in an appropriate format:
+
+- `intForColumn:`
+- `longForColumn:`
+- `longLongIntForColumn:`
+- `boolForColumn:`
+- `doubleForColumn:`
+- `stringForColumn:`
+- `dateForColumn:`
+- `dataForColumn:`
+- `dataNoCopyForColumn:`
+- `UTF8StringForColumnName:`
+- `objectForColumnName:`
+
+Each of these methods also has a `{type}ForColumnIndex:` variant that is used to retrieve the data based on the position of the column in the results, as opposed to the column's name.
+
+Typically, there's no need to `-close` an `FMResultSet` yourself, since that happens when either the result set is deallocated, or the parent database is closed.
+
+### Closing
+
+When you have finished executing queries and updates on the database, you should `-close` the `FMDatabase` connection so that SQLite will relinquish any resources it has acquired during the course of its operation.
+
+```objc
+[db close];
+```
+
+### Transactions
+
+`FMDatabase` can begin and commit a transaction by invoking one of the appropriate methods or executing a begin/end transaction statement.
+
+### Multiple Statements and Batch Stuff
+
+You can use `FMDatabase`'s executeStatements:withResultBlock: to do multiple statements in a string:
+
+```objc
+NSString *sql = @"create table bulktest1 (id integer primary key autoincrement, x text);"
+ "create table bulktest2 (id integer primary key autoincrement, y text);"
+ "create table bulktest3 (id integer primary key autoincrement, z text);"
+ "insert into bulktest1 (x) values ('XXX');"
+ "insert into bulktest2 (y) values ('YYY');"
+ "insert into bulktest3 (z) values ('ZZZ');";
+
+success = [db executeStatements:sql];
+
+sql = @"select count(*) as count from bulktest1;"
+ "select count(*) as count from bulktest2;"
+ "select count(*) as count from bulktest3;";
+
+success = [self.db executeStatements:sql withResultBlock:^int(NSDictionary *dictionary) {
+ NSInteger count = [dictionary[@"count"] integerValue];
+ XCTAssertEqual(count, 1, @"expected one record for dictionary %@", dictionary);
+ return 0;
+}];
+```
+
+### Data Sanitization
+
+When providing a SQL statement to FMDB, you should not attempt to "sanitize" any values before insertion. Instead, you should use the standard SQLite binding syntax:
+
+```sql
+INSERT INTO myTable VALUES (?, ?, ?, ?)
+```
+
+The `?` character is recognized by SQLite as a placeholder for a value to be inserted. The execution methods all accept a variable number of arguments (or a representation of those arguments, such as an `NSArray`, `NSDictionary`, or a `va_list`), which are properly escaped for you.
+
+And, to use that SQL with the `?` placeholders from Objective-C:
+
+```objc
+NSInteger identifier = 42;
+NSString *name = @"Liam O'Flaherty (\"the famous Irish author\")";
+NSDate *date = [NSDate date];
+NSString *comment = nil;
+
+BOOL success = [db executeUpdate:@"INSERT INTO authors (identifier, name, date, comment) VALUES (?, ?, ?, ?)", @(identifier), name, date, comment ?: [NSNull null]];
+if (!success) {
+ NSLog(@"error = %@", [db lastErrorMessage]);
+}
+```
+
+> **Note:** Fundamental data types, like the `NSInteger` variable `identifier`, should be as a `NSNumber` objects, achieved by using the `@` syntax, shown above. Or you can use the `[NSNumber numberWithInt:identifier]` syntax, too.
+>
+> Likewise, SQL `NULL` values should be inserted as `[NSNull null]`. For example, in the case of `comment` which might be `nil` (and is in this example), you can use the `comment ?: [NSNull null]` syntax, which will insert the string if `comment` is not `nil`, but will insert `[NSNull null]` if it is `nil`.
+
+In Swift, you would use `executeUpdate(values:)`, which not only is a concise Swift syntax, but also `throws` errors for proper Swift 2 error handling:
+
+```swift
+do {
+ let identifier = 42
+ let name = "Liam O'Flaherty (\"the famous Irish author\")"
+ let date = NSDate()
+ let comment: String? = nil
+
+ try db.executeUpdate("INSERT INTO authors (identifier, name, date, comment) VALUES (?, ?, ?, ?)", values: [identifier, name, date, comment ?? NSNull()])
+} catch {
+ print("error = \(error)")
+}
+```
+
+> **Note:** In Swift, you don't have to wrap fundamental numeric types like you do in Objective-C. But if you are going to insert an optional string, you would probably use the `comment ?? NSNull()` syntax (i.e., if it is `nil`, use `NSNull`, otherwise use the string).
+
+Alternatively, you may use named parameters syntax:
+
+```sql
+INSERT INTO authors (identifier, name, date, comment) VALUES (:identifier, :name, :date, :comment)
+```
+
+The parameters *must* start with a colon. SQLite itself supports other characters, but internally the dictionary keys are prefixed with a colon, do **not** include the colon in your dictionary keys.
+
+```objc
+NSDictionary *arguments = @{@"identifier": @(identifier), @"name": name, @"date": date, @"comment": comment ?: [NSNull null]};
+BOOL success = [db executeUpdate:@"INSERT INTO authors (identifier, name, date, comment) VALUES (:identifier, :name, :date, :comment)" withParameterDictionary:arguments];
+if (!success) {
+ NSLog(@"error = %@", [db lastErrorMessage]);
+}
+```
+
+The key point is that one should not use `NSString` method `stringWithFormat` to manually insert values into the SQL statement, itself. Nor should one Swift string interpolation to insert values into the SQL. Use `?` placeholders for values to be inserted into the database (or used in `WHERE` clauses in `SELECT` statements).
+
+
Using FMDatabaseQueue and Thread Safety.
+
+Using a single instance of `FMDatabase` from multiple threads at once is a bad idea. It has always been OK to make a `FMDatabase` object *per thread*. Just don't share a single instance across threads, and definitely not across multiple threads at the same time. Bad things will eventually happen and you'll eventually get something to crash, or maybe get an exception, or maybe meteorites will fall out of the sky and hit your Mac Pro. *This would suck*.
+
+**So don't instantiate a single `FMDatabase` object and use it across multiple threads.**
+
+Instead, use `FMDatabaseQueue`. Instantiate a single `FMDatabaseQueue` and use it across multiple threads. The `FMDatabaseQueue` object will synchronize and coordinate access across the multiple threads. Here's how to use it:
+
+First, make your queue.
+
+```objc
+FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:aPath];
+```
+
+Then use it like so:
+
+
+```objc
+[queue inDatabase:^(FMDatabase *db) {
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", @1];
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", @2];
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", @3];
+
+ FMResultSet *rs = [db executeQuery:@"select * from foo"];
+ while ([rs next]) {
+ …
+ }
+}];
+```
+
+An easy way to wrap things up in a transaction can be done like this:
+
+```objc
+[queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", @1];
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", @2];
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", @3];
+
+ if (whoopsSomethingWrongHappened) {
+ *rollback = YES;
+ return;
+ }
+ // etc…
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", @4];
+}];
+```
+
+The Swift equivalent would be:
+
+```swift
+queue.inTransaction { db, rollback in
+ do {
+ try db.executeUpdate("INSERT INTO myTable VALUES (?)", values: [1])
+ try db.executeUpdate("INSERT INTO myTable VALUES (?)", values: [2])
+ try db.executeUpdate("INSERT INTO myTable VALUES (?)", values: [3])
+
+ if whoopsSomethingWrongHappened {
+ rollback.memory = true
+ return
+ }
+
+ try db.executeUpdate("INSERT INTO myTable VALUES (?)", values: [4])
+ } catch {
+ rollback.memory = true
+ print(error)
+ }
+}
+```
+
+`FMDatabaseQueue` will run the blocks on a serialized queue (hence the name of the class). So if you call `FMDatabaseQueue`'s methods from multiple threads at the same time, they will be executed in the order they are received. This way queries and updates won't step on each other's toes, and every one is happy.
+
+**Note:** The calls to `FMDatabaseQueue`'s methods are blocking. So even though you are passing along blocks, they will **not** be run on another thread.
+
+## Making custom sqlite functions, based on blocks.
+
+You can do this! For an example, look for `-makeFunctionNamed:` in main.m
+
+## Swift
+
+You can use FMDB in Swift projects too.
+
+To do this, you must:
+
+1. Copy the relevant `.m` and `.h` files from the FMDB `src` folder into your project.
+
+ You can copy all of them (which is easiest), or only the ones you need. Likely you will need [`FMDatabase`](http://ccgus.github.io/fmdb/html/Classes/FMDatabase.html) and [`FMResultSet`](http://ccgus.github.io/fmdb/html/Classes/FMResultSet.html) at a minimum. [`FMDatabaseAdditions`](http://ccgus.github.io/fmdb/html/Categories/FMDatabase+FMDatabaseAdditions.html) provides some very useful convenience methods, so you will likely want that, too. If you are doing multithreaded access to a database, [`FMDatabaseQueue`](http://ccgus.github.io/fmdb/html/Classes/FMDatabaseQueue.html) is quite useful, too. If you choose to not copy all of the files from the `src` directory, though, you may want to update `FMDB.h` to only reference the files that you included in your project.
+
+ Note, if you're copying all of the files from the `src` folder into to your project (which is recommended), you may want to drag the individual files into your project, not the folder, itself, because if you drag the folder, you won't be prompted to add the bridging header (see next point).
+
+2. If prompted to create a "bridging header", you should do so. If not prompted and if you don't already have a bridging header, add one.
+
+ For more information on bridging headers, see [Swift and Objective-C in the Same Project](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html#//apple_ref/doc/uid/TP40014216-CH10-XID_76).
+
+3. In your bridging header, add a line that says:
+ ```objc
+ #import "FMDB.h"
+ ```
+
+4. Use the variations of `executeQuery` and `executeUpdate` with the `sql` and `values` parameters with `try` pattern, as shown below. These renditions of `executeQuery` and `executeUpdate` both `throw` errors in true Swift 2 fashion.
+
+If you do the above, you can then write Swift code that uses `FMDatabase`. For example:
+
+```swift
+let documents = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
+let fileURL = documents.URLByAppendingPathComponent("test.sqlite")
+
+let database = FMDatabase(path: fileURL.path)
+
+if !database.open() {
+ print("Unable to open database")
+ return
+}
+
+do {
+ try database.executeUpdate("create table test(x text, y text, z text)", values: nil)
+ try database.executeUpdate("insert into test (x, y, z) values (?, ?, ?)", values: ["a", "b", "c"])
+ try database.executeUpdate("insert into test (x, y, z) values (?, ?, ?)", values: ["e", "f", "g"])
+
+ let rs = try database.executeQuery("select x, y, z from test", values: nil)
+ while rs.next() {
+ let x = rs.stringForColumn("x")
+ let y = rs.stringForColumn("y")
+ let z = rs.stringForColumn("z")
+ print("x = \(x); y = \(y); z = \(z)")
+ }
+} catch let error as NSError {
+ print("failed: \(error.localizedDescription)")
+}
+
+database.close()
+```
+
+## History
+
+The history and changes are availbe on its [GitHub page](https://github.com/ccgus/fmdb) and are summarized in the "CHANGES_AND_TODO_LIST.txt" file.
+
+## Contributors
+
+The contributors to FMDB are contained in the "Contributors.txt" file.
+
+## Additional projects using FMDB, which might be interesting to the discerning developer.
+
+ * FMDBMigrationManager, A SQLite schema migration management system for FMDB: https://github.com/layerhq/FMDBMigrationManager
+ * FCModel, An alternative to Core Data for people who like having direct SQL access: https://github.com/marcoarment/FCModel
+
+## Quick notes on FMDB's coding style
+
+Spaces, not tabs. Square brackets, not dot notation. Look at what FMDB already does with curly brackets and such, and stick to that style.
+
+## Reporting bugs
+
+Reduce your bug down to the smallest amount of code possible. You want to make it super easy for the developers to see and reproduce your bug. If it helps, pretend that the person who can fix your bug is active on shipping 3 major products, works on a handful of open source projects, has a newborn baby, and is generally very very busy.
+
+And we've even added a template function to main.m (FMDBReportABugFunction) in the FMDB distribution to help you out:
+
+* Open up fmdb project in Xcode.
+* Open up main.m and modify the FMDBReportABugFunction to reproduce your bug.
+ * Setup your table(s) in the code.
+ * Make your query or update(s).
+ * Add some assertions which demonstrate the bug.
+
+Then you can bring it up on the FMDB mailing list by showing your nice and compact FMDBReportABugFunction, or you can report the bug via the github FMDB bug reporter.
+
+**Optional:**
+
+Figure out where the bug is, fix it, and send a patch in or bring that up on the mailing list. Make sure all the other tests run after your modifications.
+
+## Support
+
+The support channels for FMDB are the mailing list (see above), filing a bug here, or maybe on Stack Overflow. So that is to say, support is provided by the community and on a voluntary basis.
+
+FMDB development is overseen by Gus Mueller of Flying Meat. If FMDB been helpful to you, consider purchasing an app from FM or telling all your friends about it.
+
+## License
+
+The license for FMDB is contained in the "License.txt" file.
+
+If you happen to come across either Gus Mueller or Rob Ryan in a bar, you might consider purchasing a drink of their choosing if FMDB has been useful to you.
+
+(The drink is for them of course, shame on you for trying to keep it.)
diff --git a/ios/Pods/FMDB/src/fmdb/FMDB.h b/ios/Pods/FMDB/src/fmdb/FMDB.h
new file mode 100644
index 0000000..1ff5465
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDB.h
@@ -0,0 +1,10 @@
+#import
+
+FOUNDATION_EXPORT double FMDBVersionNumber;
+FOUNDATION_EXPORT const unsigned char FMDBVersionString[];
+
+#import "FMDatabase.h"
+#import "FMResultSet.h"
+#import "FMDatabaseAdditions.h"
+#import "FMDatabaseQueue.h"
+#import "FMDatabasePool.h"
diff --git a/ios/Pods/FMDB/src/fmdb/FMDatabase.h b/ios/Pods/FMDB/src/fmdb/FMDatabase.h
new file mode 100644
index 0000000..7dd5f8c
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDatabase.h
@@ -0,0 +1,1162 @@
+#import
+#import "FMResultSet.h"
+#import "FMDatabasePool.h"
+
+
+#if ! __has_feature(objc_arc)
+ #define FMDBAutorelease(__v) ([__v autorelease]);
+ #define FMDBReturnAutoreleased FMDBAutorelease
+
+ #define FMDBRetain(__v) ([__v retain]);
+ #define FMDBReturnRetained FMDBRetain
+
+ #define FMDBRelease(__v) ([__v release]);
+
+ #define FMDBDispatchQueueRelease(__v) (dispatch_release(__v));
+#else
+ // -fobjc-arc
+ #define FMDBAutorelease(__v)
+ #define FMDBReturnAutoreleased(__v) (__v)
+
+ #define FMDBRetain(__v)
+ #define FMDBReturnRetained(__v) (__v)
+
+ #define FMDBRelease(__v)
+
+// If OS_OBJECT_USE_OBJC=1, then the dispatch objects will be treated like ObjC objects
+// and will participate in ARC.
+// See the section on "Dispatch Queues and Automatic Reference Counting" in "Grand Central Dispatch (GCD) Reference" for details.
+ #if OS_OBJECT_USE_OBJC
+ #define FMDBDispatchQueueRelease(__v)
+ #else
+ #define FMDBDispatchQueueRelease(__v) (dispatch_release(__v));
+ #endif
+#endif
+
+#if !__has_feature(objc_instancetype)
+ #define instancetype id
+#endif
+
+
+typedef int(^FMDBExecuteStatementsCallbackBlock)(NSDictionary *resultsDictionary);
+
+
+/** A SQLite ([http://sqlite.org/](http://sqlite.org/)) Objective-C wrapper.
+
+ ### Usage
+ The three main classes in FMDB are:
+
+ - `FMDatabase` - Represents a single SQLite database. Used for executing SQL statements.
+ - `` - Represents the results of executing a query on an `FMDatabase`.
+ - `` - If you want to perform queries and updates on multiple threads, you'll want to use this class.
+
+ ### See also
+
+ - `` - A pool of `FMDatabase` objects.
+ - `` - A wrapper for `sqlite_stmt`.
+
+ ### External links
+
+ - [FMDB on GitHub](https://github.com/ccgus/fmdb) including introductory documentation
+ - [SQLite web site](http://sqlite.org/)
+ - [FMDB mailing list](http://groups.google.com/group/fmdb)
+ - [SQLite FAQ](http://www.sqlite.org/faq.html)
+
+ @warning Do not instantiate a single `FMDatabase` object and use it across multiple threads. Instead, use ``.
+
+ */
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wobjc-interface-ivars"
+
+
+@interface FMDatabase : NSObject {
+
+ void* _db;
+ NSString* _databasePath;
+ BOOL _logsErrors;
+ BOOL _crashOnErrors;
+ BOOL _traceExecution;
+ BOOL _checkedOut;
+ BOOL _shouldCacheStatements;
+ BOOL _isExecutingStatement;
+ BOOL _inTransaction;
+ NSTimeInterval _maxBusyRetryTimeInterval;
+ NSTimeInterval _startBusyRetryTime;
+
+ NSMutableDictionary *_cachedStatements;
+ NSMutableSet *_openResultSets;
+ NSMutableSet *_openFunctions;
+
+ NSDateFormatter *_dateFormat;
+}
+
+///-----------------
+/// @name Properties
+///-----------------
+
+/** Whether should trace execution */
+
+@property (atomic, assign) BOOL traceExecution;
+
+/** Whether checked out or not */
+
+@property (atomic, assign) BOOL checkedOut;
+
+/** Crash on errors */
+
+@property (atomic, assign) BOOL crashOnErrors;
+
+/** Logs errors */
+
+@property (atomic, assign) BOOL logsErrors;
+
+/** Dictionary of cached statements */
+
+@property (atomic, retain) NSMutableDictionary *cachedStatements;
+
+///---------------------
+/// @name Initialization
+///---------------------
+
+/** Create a `FMDatabase` object.
+
+ An `FMDatabase` is created with a path to a SQLite database file. This path can be one of these three:
+
+ 1. A file system path. The file does not have to exist on disk. If it does not exist, it is created for you.
+ 2. An empty string (`@""`). An empty database is created at a temporary location. This database is deleted with the `FMDatabase` connection is closed.
+ 3. `nil`. An in-memory database is created. This database will be destroyed with the `FMDatabase` connection is closed.
+
+ For example, to create/open a database in your Mac OS X `tmp` folder:
+
+ FMDatabase *db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];
+
+ Or, in iOS, you might open a database in the app's `Documents` directory:
+
+ NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
+ NSString *dbPath = [docsPath stringByAppendingPathComponent:@"test.db"];
+ FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
+
+ (For more information on temporary and in-memory databases, read the sqlite documentation on the subject: [http://www.sqlite.org/inmemorydb.html](http://www.sqlite.org/inmemorydb.html))
+
+ @param inPath Path of database file
+
+ @return `FMDatabase` object if successful; `nil` if failure.
+
+ */
+
++ (instancetype)databaseWithPath:(NSString*)inPath;
+
+/** Initialize a `FMDatabase` object.
+
+ An `FMDatabase` is created with a path to a SQLite database file. This path can be one of these three:
+
+ 1. A file system path. The file does not have to exist on disk. If it does not exist, it is created for you.
+ 2. An empty string (`@""`). An empty database is created at a temporary location. This database is deleted with the `FMDatabase` connection is closed.
+ 3. `nil`. An in-memory database is created. This database will be destroyed with the `FMDatabase` connection is closed.
+
+ For example, to create/open a database in your Mac OS X `tmp` folder:
+
+ FMDatabase *db = [FMDatabase databaseWithPath:@"/tmp/tmp.db"];
+
+ Or, in iOS, you might open a database in the app's `Documents` directory:
+
+ NSString *docsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
+ NSString *dbPath = [docsPath stringByAppendingPathComponent:@"test.db"];
+ FMDatabase *db = [FMDatabase databaseWithPath:dbPath];
+
+ (For more information on temporary and in-memory databases, read the sqlite documentation on the subject: [http://www.sqlite.org/inmemorydb.html](http://www.sqlite.org/inmemorydb.html))
+
+ @param inPath Path of database file
+
+ @return `FMDatabase` object if successful; `nil` if failure.
+
+ */
+
+- (instancetype)initWithPath:(NSString*)inPath;
+
+
+///-----------------------------------
+/// @name Opening and closing database
+///-----------------------------------
+
+/** Opening a new database connection
+
+ The database is opened for reading and writing, and is created if it does not already exist.
+
+ @return `YES` if successful, `NO` on error.
+
+ @see [sqlite3_open()](http://sqlite.org/c3ref/open.html)
+ @see openWithFlags:
+ @see close
+ */
+
+- (BOOL)open;
+
+/** Opening a new database connection with flags and an optional virtual file system (VFS)
+
+ @param flags one of the following three values, optionally combined with the `SQLITE_OPEN_NOMUTEX`, `SQLITE_OPEN_FULLMUTEX`, `SQLITE_OPEN_SHAREDCACHE`, `SQLITE_OPEN_PRIVATECACHE`, and/or `SQLITE_OPEN_URI` flags:
+
+ `SQLITE_OPEN_READONLY`
+
+ The database is opened in read-only mode. If the database does not already exist, an error is returned.
+
+ `SQLITE_OPEN_READWRITE`
+
+ The database is opened for reading and writing if possible, or reading only if the file is write protected by the operating system. In either case the database must already exist, otherwise an error is returned.
+
+ `SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE`
+
+ The database is opened for reading and writing, and is created if it does not already exist. This is the behavior that is always used for `open` method.
+
+ @return `YES` if successful, `NO` on error.
+
+ @see [sqlite3_open_v2()](http://sqlite.org/c3ref/open.html)
+ @see open
+ @see close
+ */
+
+- (BOOL)openWithFlags:(int)flags;
+
+/** Opening a new database connection with flags and an optional virtual file system (VFS)
+
+ @param flags one of the following three values, optionally combined with the `SQLITE_OPEN_NOMUTEX`, `SQLITE_OPEN_FULLMUTEX`, `SQLITE_OPEN_SHAREDCACHE`, `SQLITE_OPEN_PRIVATECACHE`, and/or `SQLITE_OPEN_URI` flags:
+
+ `SQLITE_OPEN_READONLY`
+
+ The database is opened in read-only mode. If the database does not already exist, an error is returned.
+
+ `SQLITE_OPEN_READWRITE`
+
+ The database is opened for reading and writing if possible, or reading only if the file is write protected by the operating system. In either case the database must already exist, otherwise an error is returned.
+
+ `SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE`
+
+ The database is opened for reading and writing, and is created if it does not already exist. This is the behavior that is always used for `open` method.
+
+ @param vfsName If vfs is given the value is passed to the vfs parameter of sqlite3_open_v2.
+
+ @return `YES` if successful, `NO` on error.
+
+ @see [sqlite3_open_v2()](http://sqlite.org/c3ref/open.html)
+ @see open
+ @see close
+ */
+
+- (BOOL)openWithFlags:(int)flags vfs:(NSString *)vfsName;
+
+/** Closing a database connection
+
+ @return `YES` if success, `NO` on error.
+
+ @see [sqlite3_close()](http://sqlite.org/c3ref/close.html)
+ @see open
+ @see openWithFlags:
+ */
+
+- (BOOL)close;
+
+/** Test to see if we have a good connection to the database.
+
+ This will confirm whether:
+
+ - is database open
+ - if open, it will try a simple SELECT statement and confirm that it succeeds.
+
+ @return `YES` if everything succeeds, `NO` on failure.
+ */
+
+- (BOOL)goodConnection;
+
+
+///----------------------
+/// @name Perform updates
+///----------------------
+
+/** Execute single update statement
+
+ This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html), [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) to bind values to `?` placeholders in the SQL with the optional list of parameters, and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update.
+
+ The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
+
+ @param sql The SQL to be performed, with optional `?` placeholders.
+
+ @param outErr A reference to the `NSError` pointer to be updated with an auto released `NSError` object if an error if an error occurs. If `nil`, no `NSError` object will be returned.
+
+ @param ... Optional parameters to bind to `?` placeholders in the SQL statement. These should be Objective-C objects (e.g. `NSString`, `NSNumber`, etc.), not fundamental C data types (e.g. `int`, `char *`, etc.).
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see lastError
+ @see lastErrorCode
+ @see lastErrorMessage
+ @see [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html)
+ */
+
+- (BOOL)executeUpdate:(NSString*)sql withErrorAndBindings:(NSError**)outErr, ...;
+
+/** Execute single update statement
+
+ @see executeUpdate:withErrorAndBindings:
+
+ @warning **Deprecated**: Please use `` instead.
+ */
+
+- (BOOL)update:(NSString*)sql withErrorAndBindings:(NSError**)outErr, ... __attribute__ ((deprecated));
+
+/** Execute single update statement
+
+ This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html), [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) to bind values to `?` placeholders in the SQL with the optional list of parameters, and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update.
+
+ The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
+
+ @param sql The SQL to be performed, with optional `?` placeholders.
+
+ @param ... Optional parameters to bind to `?` placeholders in the SQL statement. These should be Objective-C objects (e.g. `NSString`, `NSNumber`, etc.), not fundamental C data types (e.g. `int`, `char *`, etc.).
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see lastError
+ @see lastErrorCode
+ @see lastErrorMessage
+ @see [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html)
+
+ @note This technique supports the use of `?` placeholders in the SQL, automatically binding any supplied value parameters to those placeholders. This approach is more robust than techniques that entail using `stringWithFormat` to manually build SQL statements, which can be problematic if the values happened to include any characters that needed to be quoted.
+
+ @note If you want to use this from Swift, please note that you must include `FMDatabaseVariadic.swift` in your project. Without that, you cannot use this method directly, and instead have to use methods such as ``.
+ */
+
+- (BOOL)executeUpdate:(NSString*)sql, ...;
+
+/** Execute single update statement
+
+ This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL. Do not use `?` placeholders in the SQL if you use this method.
+
+ @param format The SQL to be performed, with `printf`-style escape sequences.
+
+ @param ... Optional parameters to bind to use in conjunction with the `printf`-style escape sequences in the SQL statement.
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see executeUpdate:
+ @see lastError
+ @see lastErrorCode
+ @see lastErrorMessage
+
+ @note This method does not technically perform a traditional printf-style replacement. What this method actually does is replace the printf-style percent sequences with a SQLite `?` placeholder, and then bind values to that placeholder. Thus the following command
+
+ [db executeUpdateWithFormat:@"INSERT INTO test (name) VALUES (%@)", @"Gus"];
+
+ is actually replacing the `%@` with `?` placeholder, and then performing something equivalent to ``
+
+ [db executeUpdate:@"INSERT INTO test (name) VALUES (?)", @"Gus"];
+
+ There are two reasons why this distinction is important. First, the printf-style escape sequences can only be used where it is permissible to use a SQLite `?` placeholder. You can use it only for values in SQL statements, but not for table names or column names or any other non-value context. This method also cannot be used in conjunction with `pragma` statements and the like. Second, note the lack of quotation marks in the SQL. The `VALUES` clause was _not_ `VALUES ('%@')` (like you might have to do if you built a SQL statement using `NSString` method `stringWithFormat`), but rather simply `VALUES (%@)`.
+ */
+
+- (BOOL)executeUpdateWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
+
+/** Execute single update statement
+
+ This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) binding any `?` placeholders in the SQL with the optional list of parameters.
+
+ The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
+
+ @param sql The SQL to be performed, with optional `?` placeholders.
+
+ @param arguments A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see executeUpdate:values:error:
+ @see lastError
+ @see lastErrorCode
+ @see lastErrorMessage
+ */
+
+- (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments;
+
+/** Execute single update statement
+
+ This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) binding any `?` placeholders in the SQL with the optional list of parameters.
+
+ The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
+
+ This is similar to ``, except that this also accepts a pointer to a `NSError` pointer, so that errors can be returned.
+
+ In Swift 2, this throws errors, as if it were defined as follows:
+
+ `func executeUpdate(sql: String!, values: [AnyObject]!) throws -> Bool`
+
+ @param sql The SQL to be performed, with optional `?` placeholders.
+
+ @param values A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
+
+ @param error A `NSError` object to receive any error object (if any).
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see lastError
+ @see lastErrorCode
+ @see lastErrorMessage
+
+ */
+
+- (BOOL)executeUpdate:(NSString*)sql values:(NSArray *)values error:(NSError * __autoreleasing *)error;
+
+/** Execute single update statement
+
+ This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL.
+
+ The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
+
+ @param sql The SQL to be performed, with optional `?` placeholders.
+
+ @param arguments A `NSDictionary` of objects keyed by column names that will be used when binding values to the `?` placeholders in the SQL statement.
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see lastError
+ @see lastErrorCode
+ @see lastErrorMessage
+*/
+
+- (BOOL)executeUpdate:(NSString*)sql withParameterDictionary:(NSDictionary *)arguments;
+
+
+/** Execute single update statement
+
+ This method executes a single SQL update statement (i.e. any SQL that does not return results, such as `UPDATE`, `INSERT`, or `DELETE`. This method employs [`sqlite3_prepare_v2`](http://sqlite.org/c3ref/prepare.html) and [`sqlite_step`](http://sqlite.org/c3ref/step.html) to perform the update. Unlike the other `executeUpdate` methods, this uses printf-style formatters (e.g. `%s`, `%d`, etc.) to build the SQL.
+
+ The optional values provided to this method should be objects (e.g. `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects), not fundamental data types (e.g. `int`, `long`, `NSInteger`, etc.). This method automatically handles the aforementioned object types, and all other object types will be interpreted as text values using the object's `description` method.
+
+ @param sql The SQL to be performed, with optional `?` placeholders.
+
+ @param args A `va_list` of arguments.
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see lastError
+ @see lastErrorCode
+ @see lastErrorMessage
+ */
+
+- (BOOL)executeUpdate:(NSString*)sql withVAList: (va_list)args;
+
+/** Execute multiple SQL statements
+
+ This executes a series of SQL statements that are combined in a single string (e.g. the SQL generated by the `sqlite3` command line `.dump` command). This accepts no value parameters, but rather simply expects a single string with multiple SQL statements, each terminated with a semicolon. This uses `sqlite3_exec`.
+
+ @param sql The SQL to be performed
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see executeStatements:withResultBlock:
+ @see [sqlite3_exec()](http://sqlite.org/c3ref/exec.html)
+
+ */
+
+- (BOOL)executeStatements:(NSString *)sql;
+
+/** Execute multiple SQL statements with callback handler
+
+ This executes a series of SQL statements that are combined in a single string (e.g. the SQL generated by the `sqlite3` command line `.dump` command). This accepts no value parameters, but rather simply expects a single string with multiple SQL statements, each terminated with a semicolon. This uses `sqlite3_exec`.
+
+ @param sql The SQL to be performed.
+ @param block A block that will be called for any result sets returned by any SQL statements.
+ Note, if you supply this block, it must return integer value, zero upon success (this would be a good opportunity to use SQLITE_OK),
+ non-zero value upon failure (which will stop the bulk execution of the SQL). If a statement returns values, the block will be called with the results from the query in NSDictionary *resultsDictionary.
+ This may be `nil` if you don't care to receive any results.
+
+ @return `YES` upon success; `NO` upon failure. If failed, you can call ``,
+ ``, or `` for diagnostic information regarding the failure.
+
+ @see executeStatements:
+ @see [sqlite3_exec()](http://sqlite.org/c3ref/exec.html)
+
+ */
+
+- (BOOL)executeStatements:(NSString *)sql withResultBlock:(FMDBExecuteStatementsCallbackBlock)block;
+
+/** Last insert rowid
+
+ Each entry in an SQLite table has a unique 64-bit signed integer key called the "rowid". The rowid is always available as an undeclared column named `ROWID`, `OID`, or `_ROWID_` as long as those names are not also used by explicitly declared columns. If the table has a column of type `INTEGER PRIMARY KEY` then that column is another alias for the rowid.
+
+ This routine returns the rowid of the most recent successful `INSERT` into the database from the database connection in the first argument. As of SQLite version 3.7.7, this routines records the last insert rowid of both ordinary tables and virtual tables. If no successful `INSERT`s have ever occurred on that database connection, zero is returned.
+
+ @return The rowid of the last inserted row.
+
+ @see [sqlite3_last_insert_rowid()](http://sqlite.org/c3ref/last_insert_rowid.html)
+
+ */
+
+- (int64_t)lastInsertRowId;
+
+/** The number of rows changed by prior SQL statement.
+
+ This function returns the number of database rows that were changed or inserted or deleted by the most recently completed SQL statement on the database connection specified by the first parameter. Only changes that are directly specified by the INSERT, UPDATE, or DELETE statement are counted.
+
+ @return The number of rows changed by prior SQL statement.
+
+ @see [sqlite3_changes()](http://sqlite.org/c3ref/changes.html)
+
+ */
+
+- (int)changes;
+
+
+///-------------------------
+/// @name Retrieving results
+///-------------------------
+
+/** Execute select statement
+
+ Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
+
+ In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
+
+ This method employs [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html) for any optional value parameters. This properly escapes any characters that need escape sequences (e.g. quotation marks), which eliminates simple SQL errors as well as protects against SQL injection attacks. This method natively handles `NSString`, `NSNumber`, `NSNull`, `NSDate`, and `NSData` objects. All other object types will be interpreted as text values using the object's `description` method.
+
+ @param sql The SELECT statement to be performed, with optional `?` placeholders.
+
+ @param ... Optional parameters to bind to `?` placeholders in the SQL statement. These should be Objective-C objects (e.g. `NSString`, `NSNumber`, etc.), not fundamental C data types (e.g. `int`, `char *`, etc.).
+
+ @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see FMResultSet
+ @see [`FMResultSet next`](<[FMResultSet next]>)
+ @see [`sqlite3_bind`](http://sqlite.org/c3ref/bind_blob.html)
+
+ @note If you want to use this from Swift, please note that you must include `FMDatabaseVariadic.swift` in your project. Without that, you cannot use this method directly, and instead have to use methods such as ``.
+ */
+
+- (FMResultSet *)executeQuery:(NSString*)sql, ...;
+
+/** Execute select statement
+
+ Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
+
+ In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
+
+ @param format The SQL to be performed, with `printf`-style escape sequences.
+
+ @param ... Optional parameters to bind to use in conjunction with the `printf`-style escape sequences in the SQL statement.
+
+ @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see executeQuery:
+ @see FMResultSet
+ @see [`FMResultSet next`](<[FMResultSet next]>)
+
+ @note This method does not technically perform a traditional printf-style replacement. What this method actually does is replace the printf-style percent sequences with a SQLite `?` placeholder, and then bind values to that placeholder. Thus the following command
+
+ [db executeQueryWithFormat:@"SELECT * FROM test WHERE name=%@", @"Gus"];
+
+ is actually replacing the `%@` with `?` placeholder, and then performing something equivalent to ``
+
+ [db executeQuery:@"SELECT * FROM test WHERE name=?", @"Gus"];
+
+ There are two reasons why this distinction is important. First, the printf-style escape sequences can only be used where it is permissible to use a SQLite `?` placeholder. You can use it only for values in SQL statements, but not for table names or column names or any other non-value context. This method also cannot be used in conjunction with `pragma` statements and the like. Second, note the lack of quotation marks in the SQL. The `WHERE` clause was _not_ `WHERE name='%@'` (like you might have to do if you built a SQL statement using `NSString` method `stringWithFormat`), but rather simply `WHERE name=%@`.
+
+ */
+
+- (FMResultSet *)executeQueryWithFormat:(NSString*)format, ... NS_FORMAT_FUNCTION(1,2);
+
+/** Execute select statement
+
+ Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
+
+ In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
+
+ @param sql The SELECT statement to be performed, with optional `?` placeholders.
+
+ @param arguments A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
+
+ @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see -executeQuery:values:error:
+ @see FMResultSet
+ @see [`FMResultSet next`](<[FMResultSet next]>)
+ */
+
+- (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)arguments;
+
+/** Execute select statement
+
+ Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
+
+ In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
+
+ This is similar to ``, except that this also accepts a pointer to a `NSError` pointer, so that errors can be returned.
+
+ In Swift 2, this throws errors, as if it were defined as follows:
+
+ `func executeQuery(sql: String!, values: [AnyObject]!) throws -> FMResultSet!`
+
+ @param sql The SELECT statement to be performed, with optional `?` placeholders.
+
+ @param values A `NSArray` of objects to be used when binding values to the `?` placeholders in the SQL statement.
+
+ @param error A `NSError` object to receive any error object (if any).
+
+ @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see FMResultSet
+ @see [`FMResultSet next`](<[FMResultSet next]>)
+
+ @note When called from Swift, only use the first two parameters, `sql` and `values`. This but throws the error.
+
+ */
+
+- (FMResultSet *)executeQuery:(NSString *)sql values:(NSArray *)values error:(NSError * __autoreleasing *)error;
+
+/** Execute select statement
+
+ Executing queries returns an `` object if successful, and `nil` upon failure. Like executing updates, there is a variant that accepts an `NSError **` parameter. Otherwise you should use the `` and `` methods to determine why a query failed.
+
+ In order to iterate through the results of your query, you use a `while()` loop. You also need to "step" (via `<[FMResultSet next]>`) from one record to the other.
+
+ @param sql The SELECT statement to be performed, with optional `?` placeholders.
+
+ @param arguments A `NSDictionary` of objects keyed by column names that will be used when binding values to the `?` placeholders in the SQL statement.
+
+ @return A `` for the result set upon success; `nil` upon failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see FMResultSet
+ @see [`FMResultSet next`](<[FMResultSet next]>)
+ */
+
+- (FMResultSet *)executeQuery:(NSString *)sql withParameterDictionary:(NSDictionary *)arguments;
+
+
+// Documentation forthcoming.
+- (FMResultSet *)executeQuery:(NSString*)sql withVAList: (va_list)args;
+
+///-------------------
+/// @name Transactions
+///-------------------
+
+/** Begin a transaction
+
+ @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see commit
+ @see rollback
+ @see beginDeferredTransaction
+ @see inTransaction
+ */
+
+- (BOOL)beginTransaction;
+
+/** Begin a deferred transaction
+
+ @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see commit
+ @see rollback
+ @see beginTransaction
+ @see inTransaction
+ */
+
+- (BOOL)beginDeferredTransaction;
+
+/** Commit a transaction
+
+ Commit a transaction that was initiated with either `` or with ``.
+
+ @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see beginTransaction
+ @see beginDeferredTransaction
+ @see rollback
+ @see inTransaction
+ */
+
+- (BOOL)commit;
+
+/** Rollback a transaction
+
+ Rollback a transaction that was initiated with either `` or with ``.
+
+ @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see beginTransaction
+ @see beginDeferredTransaction
+ @see commit
+ @see inTransaction
+ */
+
+- (BOOL)rollback;
+
+/** Identify whether currently in a transaction or not
+
+ @return `YES` if currently within transaction; `NO` if not.
+
+ @see beginTransaction
+ @see beginDeferredTransaction
+ @see commit
+ @see rollback
+ */
+
+- (BOOL)inTransaction;
+
+
+///----------------------------------------
+/// @name Cached statements and result sets
+///----------------------------------------
+
+/** Clear cached statements */
+
+- (void)clearCachedStatements;
+
+/** Close all open result sets */
+
+- (void)closeOpenResultSets;
+
+/** Whether database has any open result sets
+
+ @return `YES` if there are open result sets; `NO` if not.
+ */
+
+- (BOOL)hasOpenResultSets;
+
+/** Return whether should cache statements or not
+
+ @return `YES` if should cache statements; `NO` if not.
+ */
+
+- (BOOL)shouldCacheStatements;
+
+/** Set whether should cache statements or not
+
+ @param value `YES` if should cache statements; `NO` if not.
+ */
+
+- (void)setShouldCacheStatements:(BOOL)value;
+
+
+///-------------------------
+/// @name Encryption methods
+///-------------------------
+
+/** Set encryption key.
+
+ @param key The key to be used.
+
+ @return `YES` if success, `NO` on error.
+
+ @see https://www.zetetic.net/sqlcipher/
+
+ @warning You need to have purchased the sqlite encryption extensions for this method to work.
+ */
+
+- (BOOL)setKey:(NSString*)key;
+
+/** Reset encryption key
+
+ @param key The key to be used.
+
+ @return `YES` if success, `NO` on error.
+
+ @see https://www.zetetic.net/sqlcipher/
+
+ @warning You need to have purchased the sqlite encryption extensions for this method to work.
+ */
+
+- (BOOL)rekey:(NSString*)key;
+
+/** Set encryption key using `keyData`.
+
+ @param keyData The `NSData` to be used.
+
+ @return `YES` if success, `NO` on error.
+
+ @see https://www.zetetic.net/sqlcipher/
+
+ @warning You need to have purchased the sqlite encryption extensions for this method to work.
+ */
+
+- (BOOL)setKeyWithData:(NSData *)keyData;
+
+/** Reset encryption key using `keyData`.
+
+ @param keyData The `NSData` to be used.
+
+ @return `YES` if success, `NO` on error.
+
+ @see https://www.zetetic.net/sqlcipher/
+
+ @warning You need to have purchased the sqlite encryption extensions for this method to work.
+ */
+
+- (BOOL)rekeyWithData:(NSData *)keyData;
+
+
+///------------------------------
+/// @name General inquiry methods
+///------------------------------
+
+/** The path of the database file
+
+ @return path of database.
+
+ */
+
+- (NSString *)databasePath;
+
+/** The underlying SQLite handle
+
+ @return The `sqlite3` pointer.
+
+ */
+
+- (void*)sqliteHandle;
+
+
+///-----------------------------
+/// @name Retrieving error codes
+///-----------------------------
+
+/** Last error message
+
+ Returns the English-language text that describes the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
+
+ @return `NSString` of the last error message.
+
+ @see [sqlite3_errmsg()](http://sqlite.org/c3ref/errcode.html)
+ @see lastErrorCode
+ @see lastError
+
+ */
+
+- (NSString*)lastErrorMessage;
+
+/** Last error code
+
+ Returns the numeric result code or extended result code for the most recent failed SQLite API call associated with a database connection. If a prior API call failed but the most recent API call succeeded, this return value is undefined.
+
+ @return Integer value of the last error code.
+
+ @see [sqlite3_errcode()](http://sqlite.org/c3ref/errcode.html)
+ @see lastErrorMessage
+ @see lastError
+
+ */
+
+- (int)lastErrorCode;
+
+/** Had error
+
+ @return `YES` if there was an error, `NO` if no error.
+
+ @see lastError
+ @see lastErrorCode
+ @see lastErrorMessage
+
+ */
+
+- (BOOL)hadError;
+
+/** Last error
+
+ @return `NSError` representing the last error.
+
+ @see lastErrorCode
+ @see lastErrorMessage
+
+ */
+
+- (NSError*)lastError;
+
+
+// description forthcoming
+- (void)setMaxBusyRetryTimeInterval:(NSTimeInterval)timeoutInSeconds;
+- (NSTimeInterval)maxBusyRetryTimeInterval;
+
+
+///------------------
+/// @name Save points
+///------------------
+
+/** Start save point
+
+ @param name Name of save point.
+
+ @param outErr A `NSError` object to receive any error object (if any).
+
+ @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see releaseSavePointWithName:error:
+ @see rollbackToSavePointWithName:error:
+ */
+
+- (BOOL)startSavePointWithName:(NSString*)name error:(NSError**)outErr;
+
+/** Release save point
+
+ @param name Name of save point.
+
+ @param outErr A `NSError` object to receive any error object (if any).
+
+ @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see startSavePointWithName:error:
+ @see rollbackToSavePointWithName:error:
+
+ */
+
+- (BOOL)releaseSavePointWithName:(NSString*)name error:(NSError**)outErr;
+
+/** Roll back to save point
+
+ @param name Name of save point.
+ @param outErr A `NSError` object to receive any error object (if any).
+
+ @return `YES` on success; `NO` on failure. If failed, you can call ``, ``, or `` for diagnostic information regarding the failure.
+
+ @see startSavePointWithName:error:
+ @see releaseSavePointWithName:error:
+
+ */
+
+- (BOOL)rollbackToSavePointWithName:(NSString*)name error:(NSError**)outErr;
+
+/** Start save point
+
+ @param block Block of code to perform from within save point.
+
+ @return The NSError corresponding to the error, if any. If no error, returns `nil`.
+
+ @see startSavePointWithName:error:
+ @see releaseSavePointWithName:error:
+ @see rollbackToSavePointWithName:error:
+
+ */
+
+- (NSError*)inSavePoint:(void (^)(BOOL *rollback))block;
+
+///----------------------------
+/// @name SQLite library status
+///----------------------------
+
+/** Test to see if the library is threadsafe
+
+ @return `NO` if and only if SQLite was compiled with mutexing code omitted due to the SQLITE_THREADSAFE compile-time option being set to 0.
+
+ @see [sqlite3_threadsafe()](http://sqlite.org/c3ref/threadsafe.html)
+ */
+
++ (BOOL)isSQLiteThreadSafe;
+
+/** Run-time library version numbers
+
+ @return The sqlite library version string.
+
+ @see [sqlite3_libversion()](http://sqlite.org/c3ref/libversion.html)
+ */
+
++ (NSString*)sqliteLibVersion;
+
+
++ (NSString*)FMDBUserVersion;
+
++ (SInt32)FMDBVersion;
+
+
+///------------------------
+/// @name Make SQL function
+///------------------------
+
+/** Adds SQL functions or aggregates or to redefine the behavior of existing SQL functions or aggregates.
+
+ For example:
+
+ [queue inDatabase:^(FMDatabase *adb) {
+
+ [adb executeUpdate:@"create table ftest (foo text)"];
+ [adb executeUpdate:@"insert into ftest values ('hello')"];
+ [adb executeUpdate:@"insert into ftest values ('hi')"];
+ [adb executeUpdate:@"insert into ftest values ('not h!')"];
+ [adb executeUpdate:@"insert into ftest values ('definitely not h!')"];
+
+ [adb makeFunctionNamed:@"StringStartsWithH" maximumArguments:1 withBlock:^(sqlite3_context *context, int aargc, sqlite3_value **aargv) {
+ if (sqlite3_value_type(aargv[0]) == SQLITE_TEXT) {
+ @autoreleasepool {
+ const char *c = (const char *)sqlite3_value_text(aargv[0]);
+ NSString *s = [NSString stringWithUTF8String:c];
+ sqlite3_result_int(context, [s hasPrefix:@"h"]);
+ }
+ }
+ else {
+ NSLog(@"Unknown formart for StringStartsWithH (%d) %s:%d", sqlite3_value_type(aargv[0]), __FUNCTION__, __LINE__);
+ sqlite3_result_null(context);
+ }
+ }];
+
+ int rowCount = 0;
+ FMResultSet *ars = [adb executeQuery:@"select * from ftest where StringStartsWithH(foo)"];
+ while ([ars next]) {
+ rowCount++;
+ NSLog(@"Does %@ start with 'h'?", [rs stringForColumnIndex:0]);
+ }
+ FMDBQuickCheck(rowCount == 2);
+ }];
+
+ @param name Name of function
+
+ @param count Maximum number of parameters
+
+ @param block The block of code for the function
+
+ @see [sqlite3_create_function()](http://sqlite.org/c3ref/create_function.html)
+ */
+
+- (void)makeFunctionNamed:(NSString*)name maximumArguments:(int)count withBlock:(void (^)(void *context, int argc, void **argv))block;
+
+
+///---------------------
+/// @name Date formatter
+///---------------------
+
+/** Generate an `NSDateFormatter` that won't be broken by permutations of timezones or locales.
+
+ Use this method to generate values to set the dateFormat property.
+
+ Example:
+
+ myDB.dateFormat = [FMDatabase storeableDateFormat:@"yyyy-MM-dd HH:mm:ss"];
+
+ @param format A valid NSDateFormatter format string.
+
+ @return A `NSDateFormatter` that can be used for converting dates to strings and vice versa.
+
+ @see hasDateFormatter
+ @see setDateFormat:
+ @see dateFromString:
+ @see stringFromDate:
+ @see storeableDateFormat:
+
+ @warning Note that `NSDateFormatter` is not thread-safe, so the formatter generated by this method should be assigned to only one FMDB instance and should not be used for other purposes.
+
+ */
+
++ (NSDateFormatter *)storeableDateFormat:(NSString *)format;
+
+/** Test whether the database has a date formatter assigned.
+
+ @return `YES` if there is a date formatter; `NO` if not.
+
+ @see hasDateFormatter
+ @see setDateFormat:
+ @see dateFromString:
+ @see stringFromDate:
+ @see storeableDateFormat:
+ */
+
+- (BOOL)hasDateFormatter;
+
+/** Set to a date formatter to use string dates with sqlite instead of the default UNIX timestamps.
+
+ @param format Set to nil to use UNIX timestamps. Defaults to nil. Should be set using a formatter generated using FMDatabase::storeableDateFormat.
+
+ @see hasDateFormatter
+ @see setDateFormat:
+ @see dateFromString:
+ @see stringFromDate:
+ @see storeableDateFormat:
+
+ @warning Note there is no direct getter for the `NSDateFormatter`, and you should not use the formatter you pass to FMDB for other purposes, as `NSDateFormatter` is not thread-safe.
+ */
+
+- (void)setDateFormat:(NSDateFormatter *)format;
+
+/** Convert the supplied NSString to NSDate, using the current database formatter.
+
+ @param s `NSString` to convert to `NSDate`.
+
+ @return The `NSDate` object; or `nil` if no formatter is set.
+
+ @see hasDateFormatter
+ @see setDateFormat:
+ @see dateFromString:
+ @see stringFromDate:
+ @see storeableDateFormat:
+ */
+
+- (NSDate *)dateFromString:(NSString *)s;
+
+/** Convert the supplied NSDate to NSString, using the current database formatter.
+
+ @param date `NSDate` of date to convert to `NSString`.
+
+ @return The `NSString` representation of the date; `nil` if no formatter is set.
+
+ @see hasDateFormatter
+ @see setDateFormat:
+ @see dateFromString:
+ @see stringFromDate:
+ @see storeableDateFormat:
+ */
+
+- (NSString *)stringFromDate:(NSDate *)date;
+
+@end
+
+
+/** Objective-C wrapper for `sqlite3_stmt`
+
+ This is a wrapper for a SQLite `sqlite3_stmt`. Generally when using FMDB you will not need to interact directly with `FMStatement`, but rather with `` and `` only.
+
+ ### See also
+
+ - ``
+ - ``
+ - [`sqlite3_stmt`](http://www.sqlite.org/c3ref/stmt.html)
+ */
+
+@interface FMStatement : NSObject {
+ void *_statement;
+ NSString *_query;
+ long _useCount;
+ BOOL _inUse;
+}
+
+///-----------------
+/// @name Properties
+///-----------------
+
+/** Usage count */
+
+@property (atomic, assign) long useCount;
+
+/** SQL statement */
+
+@property (atomic, retain) NSString *query;
+
+/** SQLite sqlite3_stmt
+
+ @see [`sqlite3_stmt`](http://www.sqlite.org/c3ref/stmt.html)
+ */
+
+@property (atomic, assign) void *statement;
+
+/** Indication of whether the statement is in use */
+
+@property (atomic, assign) BOOL inUse;
+
+///----------------------------
+/// @name Closing and Resetting
+///----------------------------
+
+/** Close statement */
+
+- (void)close;
+
+/** Reset statement */
+
+- (void)reset;
+
+@end
+
+#pragma clang diagnostic pop
+
diff --git a/ios/Pods/FMDB/src/fmdb/FMDatabase.m b/ios/Pods/FMDB/src/fmdb/FMDatabase.m
new file mode 100644
index 0000000..27ae0f2
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDatabase.m
@@ -0,0 +1,1473 @@
+#import "FMDatabase.h"
+#import "unistd.h"
+#import
+
+#if FMDB_SQLITE_STANDALONE
+#import
+#else
+#import
+#endif
+
+@interface FMDatabase ()
+
+- (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args;
+- (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args;
+
+@end
+
+@implementation FMDatabase
+@synthesize cachedStatements=_cachedStatements;
+@synthesize logsErrors=_logsErrors;
+@synthesize crashOnErrors=_crashOnErrors;
+@synthesize checkedOut=_checkedOut;
+@synthesize traceExecution=_traceExecution;
+
+#pragma mark FMDatabase instantiation and deallocation
+
++ (instancetype)databaseWithPath:(NSString*)aPath {
+ return FMDBReturnAutoreleased([[self alloc] initWithPath:aPath]);
+}
+
+- (instancetype)init {
+ return [self initWithPath:nil];
+}
+
+- (instancetype)initWithPath:(NSString*)aPath {
+
+ assert(sqlite3_threadsafe()); // whoa there big boy- gotta make sure sqlite it happy with what we're going to do.
+
+ self = [super init];
+
+ if (self) {
+ _databasePath = [aPath copy];
+ _openResultSets = [[NSMutableSet alloc] init];
+ _db = nil;
+ _logsErrors = YES;
+ _crashOnErrors = NO;
+ _maxBusyRetryTimeInterval = 2;
+ }
+
+ return self;
+}
+
+- (void)finalize {
+ [self close];
+ [super finalize];
+}
+
+- (void)dealloc {
+ [self close];
+ FMDBRelease(_openResultSets);
+ FMDBRelease(_cachedStatements);
+ FMDBRelease(_dateFormat);
+ FMDBRelease(_databasePath);
+ FMDBRelease(_openFunctions);
+
+#if ! __has_feature(objc_arc)
+ [super dealloc];
+#endif
+}
+
+- (NSString *)databasePath {
+ return _databasePath;
+}
+
++ (NSString*)FMDBUserVersion {
+ return @"2.6";
+}
+
+// returns 0x0240 for version 2.4. This makes it super easy to do things like:
+// /* need to make sure to do X with FMDB version 2.4 or later */
+// if ([FMDatabase FMDBVersion] >= 0x0240) { … }
+
++ (SInt32)FMDBVersion {
+
+ // we go through these hoops so that we only have to change the version number in a single spot.
+ static dispatch_once_t once;
+ static SInt32 FMDBVersionVal = 0;
+
+ dispatch_once(&once, ^{
+ NSString *prodVersion = [self FMDBUserVersion];
+
+ if ([[prodVersion componentsSeparatedByString:@"."] count] < 3) {
+ prodVersion = [prodVersion stringByAppendingString:@".0"];
+ }
+
+ NSString *junk = [prodVersion stringByReplacingOccurrencesOfString:@"." withString:@""];
+
+ char *e = nil;
+ FMDBVersionVal = (int) strtoul([junk UTF8String], &e, 16);
+
+ });
+
+
+ return FMDBVersionVal;
+}
+
+#pragma mark SQLite information
+
++ (NSString*)sqliteLibVersion {
+ return [NSString stringWithFormat:@"%s", sqlite3_libversion()];
+}
+
++ (BOOL)isSQLiteThreadSafe {
+ // make sure to read the sqlite headers on this guy!
+ return sqlite3_threadsafe() != 0;
+}
+
+- (void*)sqliteHandle {
+ return _db;
+}
+
+- (const char*)sqlitePath {
+
+ if (!_databasePath) {
+ return ":memory:";
+ }
+
+ if ([_databasePath length] == 0) {
+ return ""; // this creates a temporary database (it's an sqlite thing).
+ }
+
+ return [_databasePath fileSystemRepresentation];
+
+}
+
+#pragma mark Open and close database
+
+- (BOOL)open {
+ if (_db) {
+ return YES;
+ }
+
+ int err = sqlite3_open([self sqlitePath], (sqlite3**)&_db );
+ if(err != SQLITE_OK) {
+ NSLog(@"error opening!: %d", err);
+ return NO;
+ }
+
+ if (_maxBusyRetryTimeInterval > 0.0) {
+ // set the handler
+ [self setMaxBusyRetryTimeInterval:_maxBusyRetryTimeInterval];
+ }
+
+
+ return YES;
+}
+
+- (BOOL)openWithFlags:(int)flags {
+ return [self openWithFlags:flags vfs:nil];
+}
+- (BOOL)openWithFlags:(int)flags vfs:(NSString *)vfsName {
+#if SQLITE_VERSION_NUMBER >= 3005000
+ if (_db) {
+ return YES;
+ }
+
+ int err = sqlite3_open_v2([self sqlitePath], (sqlite3**)&_db, flags, [vfsName UTF8String]);
+ if(err != SQLITE_OK) {
+ NSLog(@"error opening!: %d", err);
+ return NO;
+ }
+
+ if (_maxBusyRetryTimeInterval > 0.0) {
+ // set the handler
+ [self setMaxBusyRetryTimeInterval:_maxBusyRetryTimeInterval];
+ }
+
+ return YES;
+#else
+ NSLog(@"openWithFlags requires SQLite 3.5");
+ return NO;
+#endif
+}
+
+
+- (BOOL)close {
+
+ [self clearCachedStatements];
+ [self closeOpenResultSets];
+
+ if (!_db) {
+ return YES;
+ }
+
+ int rc;
+ BOOL retry;
+ BOOL triedFinalizingOpenStatements = NO;
+
+ do {
+ retry = NO;
+ rc = sqlite3_close(_db);
+ if (SQLITE_BUSY == rc || SQLITE_LOCKED == rc) {
+ if (!triedFinalizingOpenStatements) {
+ triedFinalizingOpenStatements = YES;
+ sqlite3_stmt *pStmt;
+ while ((pStmt = sqlite3_next_stmt(_db, nil)) !=0) {
+ NSLog(@"Closing leaked statement");
+ sqlite3_finalize(pStmt);
+ retry = YES;
+ }
+ }
+ }
+ else if (SQLITE_OK != rc) {
+ NSLog(@"error closing!: %d", rc);
+ }
+ }
+ while (retry);
+
+ _db = nil;
+ return YES;
+}
+
+#pragma mark Busy handler routines
+
+// NOTE: appledoc seems to choke on this function for some reason;
+// so when generating documentation, you might want to ignore the
+// .m files so that it only documents the public interfaces outlined
+// in the .h files.
+//
+// This is a known appledoc bug that it has problems with C functions
+// within a class implementation, but for some reason, only this
+// C function causes problems; the rest don't. Anyway, ignoring the .m
+// files with appledoc will prevent this problem from occurring.
+
+static int FMDBDatabaseBusyHandler(void *f, int count) {
+ FMDatabase *self = (__bridge FMDatabase*)f;
+
+ if (count == 0) {
+ self->_startBusyRetryTime = [NSDate timeIntervalSinceReferenceDate];
+ return 1;
+ }
+
+ NSTimeInterval delta = [NSDate timeIntervalSinceReferenceDate] - (self->_startBusyRetryTime);
+
+ if (delta < [self maxBusyRetryTimeInterval]) {
+ int requestedSleepInMillseconds = (int) arc4random_uniform(50) + 50;
+ int actualSleepInMilliseconds = sqlite3_sleep(requestedSleepInMillseconds);
+ if (actualSleepInMilliseconds != requestedSleepInMillseconds) {
+ NSLog(@"WARNING: Requested sleep of %i milliseconds, but SQLite returned %i. Maybe SQLite wasn't built with HAVE_USLEEP=1?", requestedSleepInMillseconds, actualSleepInMilliseconds);
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+- (void)setMaxBusyRetryTimeInterval:(NSTimeInterval)timeout {
+
+ _maxBusyRetryTimeInterval = timeout;
+
+ if (!_db) {
+ return;
+ }
+
+ if (timeout > 0) {
+ sqlite3_busy_handler(_db, &FMDBDatabaseBusyHandler, (__bridge void *)(self));
+ }
+ else {
+ // turn it off otherwise
+ sqlite3_busy_handler(_db, nil, nil);
+ }
+}
+
+- (NSTimeInterval)maxBusyRetryTimeInterval {
+ return _maxBusyRetryTimeInterval;
+}
+
+
+// we no longer make busyRetryTimeout public
+// but for folks who don't bother noticing that the interface to FMDatabase changed,
+// we'll still implement the method so they don't get suprise crashes
+- (int)busyRetryTimeout {
+ NSLog(@"%s:%d", __FUNCTION__, __LINE__);
+ NSLog(@"FMDB: busyRetryTimeout no longer works, please use maxBusyRetryTimeInterval");
+ return -1;
+}
+
+- (void)setBusyRetryTimeout:(int)i {
+#pragma unused(i)
+ NSLog(@"%s:%d", __FUNCTION__, __LINE__);
+ NSLog(@"FMDB: setBusyRetryTimeout does nothing, please use setMaxBusyRetryTimeInterval:");
+}
+
+#pragma mark Result set functions
+
+- (BOOL)hasOpenResultSets {
+ return [_openResultSets count] > 0;
+}
+
+- (void)closeOpenResultSets {
+
+ //Copy the set so we don't get mutation errors
+ NSSet *openSetCopy = FMDBReturnAutoreleased([_openResultSets copy]);
+ for (NSValue *rsInWrappedInATastyValueMeal in openSetCopy) {
+ FMResultSet *rs = (FMResultSet *)[rsInWrappedInATastyValueMeal pointerValue];
+
+ [rs setParentDB:nil];
+ [rs close];
+
+ [_openResultSets removeObject:rsInWrappedInATastyValueMeal];
+ }
+}
+
+- (void)resultSetDidClose:(FMResultSet *)resultSet {
+ NSValue *setValue = [NSValue valueWithNonretainedObject:resultSet];
+
+ [_openResultSets removeObject:setValue];
+}
+
+#pragma mark Cached statements
+
+- (void)clearCachedStatements {
+
+ for (NSMutableSet *statements in [_cachedStatements objectEnumerator]) {
+ [statements makeObjectsPerformSelector:@selector(close)];
+ }
+
+ [_cachedStatements removeAllObjects];
+}
+
+- (FMStatement*)cachedStatementForQuery:(NSString*)query {
+
+ NSMutableSet* statements = [_cachedStatements objectForKey:query];
+
+ return [[statements objectsPassingTest:^BOOL(FMStatement* statement, BOOL *stop) {
+
+ *stop = ![statement inUse];
+ return *stop;
+
+ }] anyObject];
+}
+
+
+- (void)setCachedStatement:(FMStatement*)statement forQuery:(NSString*)query {
+
+ query = [query copy]; // in case we got handed in a mutable string...
+ [statement setQuery:query];
+
+ NSMutableSet* statements = [_cachedStatements objectForKey:query];
+ if (!statements) {
+ statements = [NSMutableSet set];
+ }
+
+ [statements addObject:statement];
+
+ [_cachedStatements setObject:statements forKey:query];
+
+ FMDBRelease(query);
+}
+
+#pragma mark Key routines
+
+- (BOOL)rekey:(NSString*)key {
+ NSData *keyData = [NSData dataWithBytes:(void *)[key UTF8String] length:(NSUInteger)strlen([key UTF8String])];
+
+ return [self rekeyWithData:keyData];
+}
+
+- (BOOL)rekeyWithData:(NSData *)keyData {
+#ifdef SQLITE_HAS_CODEC
+ if (!keyData) {
+ return NO;
+ }
+
+ int rc = sqlite3_rekey(_db, [keyData bytes], (int)[keyData length]);
+
+ if (rc != SQLITE_OK) {
+ NSLog(@"error on rekey: %d", rc);
+ NSLog(@"%@", [self lastErrorMessage]);
+ }
+
+ return (rc == SQLITE_OK);
+#else
+#pragma unused(keyData)
+ return NO;
+#endif
+}
+
+- (BOOL)setKey:(NSString*)key {
+ NSData *keyData = [NSData dataWithBytes:[key UTF8String] length:(NSUInteger)strlen([key UTF8String])];
+
+ return [self setKeyWithData:keyData];
+}
+
+- (BOOL)setKeyWithData:(NSData *)keyData {
+#ifdef SQLITE_HAS_CODEC
+ if (!keyData) {
+ return NO;
+ }
+
+ int rc = sqlite3_key(_db, [keyData bytes], (int)[keyData length]);
+
+ return (rc == SQLITE_OK);
+#else
+#pragma unused(keyData)
+ return NO;
+#endif
+}
+
+#pragma mark Date routines
+
++ (NSDateFormatter *)storeableDateFormat:(NSString *)format {
+
+ NSDateFormatter *result = FMDBReturnAutoreleased([[NSDateFormatter alloc] init]);
+ result.dateFormat = format;
+ result.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
+ result.locale = FMDBReturnAutoreleased([[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]);
+ return result;
+}
+
+
+- (BOOL)hasDateFormatter {
+ return _dateFormat != nil;
+}
+
+- (void)setDateFormat:(NSDateFormatter *)format {
+ FMDBAutorelease(_dateFormat);
+ _dateFormat = FMDBReturnRetained(format);
+}
+
+- (NSDate *)dateFromString:(NSString *)s {
+ return [_dateFormat dateFromString:s];
+}
+
+- (NSString *)stringFromDate:(NSDate *)date {
+ return [_dateFormat stringFromDate:date];
+}
+
+#pragma mark State of database
+
+- (BOOL)goodConnection {
+
+ if (!_db) {
+ return NO;
+ }
+
+ FMResultSet *rs = [self executeQuery:@"select name from sqlite_master where type='table'"];
+
+ if (rs) {
+ [rs close];
+ return YES;
+ }
+
+ return NO;
+}
+
+- (void)warnInUse {
+ NSLog(@"The FMDatabase %@ is currently in use.", self);
+
+#ifndef NS_BLOCK_ASSERTIONS
+ if (_crashOnErrors) {
+ NSAssert(false, @"The FMDatabase %@ is currently in use.", self);
+ abort();
+ }
+#endif
+}
+
+- (BOOL)databaseExists {
+
+ if (!_db) {
+
+ NSLog(@"The FMDatabase %@ is not open.", self);
+
+ #ifndef NS_BLOCK_ASSERTIONS
+ if (_crashOnErrors) {
+ NSAssert(false, @"The FMDatabase %@ is not open.", self);
+ abort();
+ }
+ #endif
+
+ return NO;
+ }
+
+ return YES;
+}
+
+#pragma mark Error routines
+
+- (NSString*)lastErrorMessage {
+ return [NSString stringWithUTF8String:sqlite3_errmsg(_db)];
+}
+
+- (BOOL)hadError {
+ int lastErrCode = [self lastErrorCode];
+
+ return (lastErrCode > SQLITE_OK && lastErrCode < SQLITE_ROW);
+}
+
+- (int)lastErrorCode {
+ return sqlite3_errcode(_db);
+}
+
+- (NSError*)errorWithMessage:(NSString*)message {
+ NSDictionary* errorMessage = [NSDictionary dictionaryWithObject:message forKey:NSLocalizedDescriptionKey];
+
+ return [NSError errorWithDomain:@"FMDatabase" code:sqlite3_errcode(_db) userInfo:errorMessage];
+}
+
+- (NSError*)lastError {
+ return [self errorWithMessage:[self lastErrorMessage]];
+}
+
+#pragma mark Update information routines
+
+- (sqlite_int64)lastInsertRowId {
+
+ if (_isExecutingStatement) {
+ [self warnInUse];
+ return NO;
+ }
+
+ _isExecutingStatement = YES;
+
+ sqlite_int64 ret = sqlite3_last_insert_rowid(_db);
+
+ _isExecutingStatement = NO;
+
+ return ret;
+}
+
+- (int)changes {
+ if (_isExecutingStatement) {
+ [self warnInUse];
+ return 0;
+ }
+
+ _isExecutingStatement = YES;
+
+ int ret = sqlite3_changes(_db);
+
+ _isExecutingStatement = NO;
+
+ return ret;
+}
+
+#pragma mark SQL manipulation
+
+- (void)bindObject:(id)obj toColumn:(int)idx inStatement:(sqlite3_stmt*)pStmt {
+
+ if ((!obj) || ((NSNull *)obj == [NSNull null])) {
+ sqlite3_bind_null(pStmt, idx);
+ }
+
+ // FIXME - someday check the return codes on these binds.
+ else if ([obj isKindOfClass:[NSData class]]) {
+ const void *bytes = [obj bytes];
+ if (!bytes) {
+ // it's an empty NSData object, aka [NSData data].
+ // Don't pass a NULL pointer, or sqlite will bind a SQL null instead of a blob.
+ bytes = "";
+ }
+ sqlite3_bind_blob(pStmt, idx, bytes, (int)[obj length], SQLITE_STATIC);
+ }
+ else if ([obj isKindOfClass:[NSDate class]]) {
+ if (self.hasDateFormatter)
+ sqlite3_bind_text(pStmt, idx, [[self stringFromDate:obj] UTF8String], -1, SQLITE_STATIC);
+ else
+ sqlite3_bind_double(pStmt, idx, [obj timeIntervalSince1970]);
+ }
+ else if ([obj isKindOfClass:[NSNumber class]]) {
+
+ if (strcmp([obj objCType], @encode(char)) == 0) {
+ sqlite3_bind_int(pStmt, idx, [obj charValue]);
+ }
+ else if (strcmp([obj objCType], @encode(unsigned char)) == 0) {
+ sqlite3_bind_int(pStmt, idx, [obj unsignedCharValue]);
+ }
+ else if (strcmp([obj objCType], @encode(short)) == 0) {
+ sqlite3_bind_int(pStmt, idx, [obj shortValue]);
+ }
+ else if (strcmp([obj objCType], @encode(unsigned short)) == 0) {
+ sqlite3_bind_int(pStmt, idx, [obj unsignedShortValue]);
+ }
+ else if (strcmp([obj objCType], @encode(int)) == 0) {
+ sqlite3_bind_int(pStmt, idx, [obj intValue]);
+ }
+ else if (strcmp([obj objCType], @encode(unsigned int)) == 0) {
+ sqlite3_bind_int64(pStmt, idx, (long long)[obj unsignedIntValue]);
+ }
+ else if (strcmp([obj objCType], @encode(long)) == 0) {
+ sqlite3_bind_int64(pStmt, idx, [obj longValue]);
+ }
+ else if (strcmp([obj objCType], @encode(unsigned long)) == 0) {
+ sqlite3_bind_int64(pStmt, idx, (long long)[obj unsignedLongValue]);
+ }
+ else if (strcmp([obj objCType], @encode(long long)) == 0) {
+ sqlite3_bind_int64(pStmt, idx, [obj longLongValue]);
+ }
+ else if (strcmp([obj objCType], @encode(unsigned long long)) == 0) {
+ sqlite3_bind_int64(pStmt, idx, (long long)[obj unsignedLongLongValue]);
+ }
+ else if (strcmp([obj objCType], @encode(float)) == 0) {
+ sqlite3_bind_double(pStmt, idx, [obj floatValue]);
+ }
+ else if (strcmp([obj objCType], @encode(double)) == 0) {
+ sqlite3_bind_double(pStmt, idx, [obj doubleValue]);
+ }
+ else if (strcmp([obj objCType], @encode(BOOL)) == 0) {
+ sqlite3_bind_int(pStmt, idx, ([obj boolValue] ? 1 : 0));
+ }
+ else {
+ sqlite3_bind_text(pStmt, idx, [[obj description] UTF8String], -1, SQLITE_STATIC);
+ }
+ }
+ else {
+ sqlite3_bind_text(pStmt, idx, [[obj description] UTF8String], -1, SQLITE_STATIC);
+ }
+}
+
+- (void)extractSQL:(NSString *)sql argumentsList:(va_list)args intoString:(NSMutableString *)cleanedSQL arguments:(NSMutableArray *)arguments {
+
+ NSUInteger length = [sql length];
+ unichar last = '\0';
+ for (NSUInteger i = 0; i < length; ++i) {
+ id arg = nil;
+ unichar current = [sql characterAtIndex:i];
+ unichar add = current;
+ if (last == '%') {
+ switch (current) {
+ case '@':
+ arg = va_arg(args, id);
+ break;
+ case 'c':
+ // warning: second argument to 'va_arg' is of promotable type 'char'; this va_arg has undefined behavior because arguments will be promoted to 'int'
+ arg = [NSString stringWithFormat:@"%c", va_arg(args, int)];
+ break;
+ case 's':
+ arg = [NSString stringWithUTF8String:va_arg(args, char*)];
+ break;
+ case 'd':
+ case 'D':
+ case 'i':
+ arg = [NSNumber numberWithInt:va_arg(args, int)];
+ break;
+ case 'u':
+ case 'U':
+ arg = [NSNumber numberWithUnsignedInt:va_arg(args, unsigned int)];
+ break;
+ case 'h':
+ i++;
+ if (i < length && [sql characterAtIndex:i] == 'i') {
+ // warning: second argument to 'va_arg' is of promotable type 'short'; this va_arg has undefined behavior because arguments will be promoted to 'int'
+ arg = [NSNumber numberWithShort:(short)(va_arg(args, int))];
+ }
+ else if (i < length && [sql characterAtIndex:i] == 'u') {
+ // warning: second argument to 'va_arg' is of promotable type 'unsigned short'; this va_arg has undefined behavior because arguments will be promoted to 'int'
+ arg = [NSNumber numberWithUnsignedShort:(unsigned short)(va_arg(args, uint))];
+ }
+ else {
+ i--;
+ }
+ break;
+ case 'q':
+ i++;
+ if (i < length && [sql characterAtIndex:i] == 'i') {
+ arg = [NSNumber numberWithLongLong:va_arg(args, long long)];
+ }
+ else if (i < length && [sql characterAtIndex:i] == 'u') {
+ arg = [NSNumber numberWithUnsignedLongLong:va_arg(args, unsigned long long)];
+ }
+ else {
+ i--;
+ }
+ break;
+ case 'f':
+ arg = [NSNumber numberWithDouble:va_arg(args, double)];
+ break;
+ case 'g':
+ // warning: second argument to 'va_arg' is of promotable type 'float'; this va_arg has undefined behavior because arguments will be promoted to 'double'
+ arg = [NSNumber numberWithFloat:(float)(va_arg(args, double))];
+ break;
+ case 'l':
+ i++;
+ if (i < length) {
+ unichar next = [sql characterAtIndex:i];
+ if (next == 'l') {
+ i++;
+ if (i < length && [sql characterAtIndex:i] == 'd') {
+ //%lld
+ arg = [NSNumber numberWithLongLong:va_arg(args, long long)];
+ }
+ else if (i < length && [sql characterAtIndex:i] == 'u') {
+ //%llu
+ arg = [NSNumber numberWithUnsignedLongLong:va_arg(args, unsigned long long)];
+ }
+ else {
+ i--;
+ }
+ }
+ else if (next == 'd') {
+ //%ld
+ arg = [NSNumber numberWithLong:va_arg(args, long)];
+ }
+ else if (next == 'u') {
+ //%lu
+ arg = [NSNumber numberWithUnsignedLong:va_arg(args, unsigned long)];
+ }
+ else {
+ i--;
+ }
+ }
+ else {
+ i--;
+ }
+ break;
+ default:
+ // something else that we can't interpret. just pass it on through like normal
+ break;
+ }
+ }
+ else if (current == '%') {
+ // percent sign; skip this character
+ add = '\0';
+ }
+
+ if (arg != nil) {
+ [cleanedSQL appendString:@"?"];
+ [arguments addObject:arg];
+ }
+ else if (add == (unichar)'@' && last == (unichar) '%') {
+ [cleanedSQL appendFormat:@"NULL"];
+ }
+ else if (add != '\0') {
+ [cleanedSQL appendFormat:@"%C", add];
+ }
+ last = current;
+ }
+}
+
+#pragma mark Execute queries
+
+- (FMResultSet *)executeQuery:(NSString *)sql withParameterDictionary:(NSDictionary *)arguments {
+ return [self executeQuery:sql withArgumentsInArray:nil orDictionary:arguments orVAList:nil];
+}
+
+- (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args {
+
+ if (![self databaseExists]) {
+ return 0x00;
+ }
+
+ if (_isExecutingStatement) {
+ [self warnInUse];
+ return 0x00;
+ }
+
+ _isExecutingStatement = YES;
+
+ int rc = 0x00;
+ sqlite3_stmt *pStmt = 0x00;
+ FMStatement *statement = 0x00;
+ FMResultSet *rs = 0x00;
+
+ if (_traceExecution && sql) {
+ NSLog(@"%@ executeQuery: %@", self, sql);
+ }
+
+ if (_shouldCacheStatements) {
+ statement = [self cachedStatementForQuery:sql];
+ pStmt = statement ? [statement statement] : 0x00;
+ [statement reset];
+ }
+
+ if (!pStmt) {
+
+ rc = sqlite3_prepare_v2(_db, [sql UTF8String], -1, &pStmt, 0);
+
+ if (SQLITE_OK != rc) {
+ if (_logsErrors) {
+ NSLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]);
+ NSLog(@"DB Query: %@", sql);
+ NSLog(@"DB Path: %@", _databasePath);
+ }
+
+ if (_crashOnErrors) {
+ NSAssert(false, @"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]);
+ abort();
+ }
+
+ sqlite3_finalize(pStmt);
+ _isExecutingStatement = NO;
+ return nil;
+ }
+ }
+
+ id obj;
+ int idx = 0;
+ int queryCount = sqlite3_bind_parameter_count(pStmt); // pointed out by Dominic Yu (thanks!)
+
+ // If dictionaryArgs is passed in, that means we are using sqlite's named parameter support
+ if (dictionaryArgs) {
+
+ for (NSString *dictionaryKey in [dictionaryArgs allKeys]) {
+
+ // Prefix the key with a colon.
+ NSString *parameterName = [[NSString alloc] initWithFormat:@":%@", dictionaryKey];
+
+ if (_traceExecution) {
+ NSLog(@"%@ = %@", parameterName, [dictionaryArgs objectForKey:dictionaryKey]);
+ }
+
+ // Get the index for the parameter name.
+ int namedIdx = sqlite3_bind_parameter_index(pStmt, [parameterName UTF8String]);
+
+ FMDBRelease(parameterName);
+
+ if (namedIdx > 0) {
+ // Standard binding from here.
+ [self bindObject:[dictionaryArgs objectForKey:dictionaryKey] toColumn:namedIdx inStatement:pStmt];
+ // increment the binding count, so our check below works out
+ idx++;
+ }
+ else {
+ NSLog(@"Could not find index for %@", dictionaryKey);
+ }
+ }
+ }
+ else {
+
+ while (idx < queryCount) {
+
+ if (arrayArgs && idx < (int)[arrayArgs count]) {
+ obj = [arrayArgs objectAtIndex:(NSUInteger)idx];
+ }
+ else if (args) {
+ obj = va_arg(args, id);
+ }
+ else {
+ //We ran out of arguments
+ break;
+ }
+
+ if (_traceExecution) {
+ if ([obj isKindOfClass:[NSData class]]) {
+ NSLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]);
+ }
+ else {
+ NSLog(@"obj: %@", obj);
+ }
+ }
+
+ idx++;
+
+ [self bindObject:obj toColumn:idx inStatement:pStmt];
+ }
+ }
+
+ if (idx != queryCount) {
+ NSLog(@"Error: the bind count is not correct for the # of variables (executeQuery)");
+ sqlite3_finalize(pStmt);
+ _isExecutingStatement = NO;
+ return nil;
+ }
+
+ FMDBRetain(statement); // to balance the release below
+
+ if (!statement) {
+ statement = [[FMStatement alloc] init];
+ [statement setStatement:pStmt];
+
+ if (_shouldCacheStatements && sql) {
+ [self setCachedStatement:statement forQuery:sql];
+ }
+ }
+
+ // the statement gets closed in rs's dealloc or [rs close];
+ rs = [FMResultSet resultSetWithStatement:statement usingParentDatabase:self];
+ [rs setQuery:sql];
+
+ NSValue *openResultSet = [NSValue valueWithNonretainedObject:rs];
+ [_openResultSets addObject:openResultSet];
+
+ [statement setUseCount:[statement useCount] + 1];
+
+ FMDBRelease(statement);
+
+ _isExecutingStatement = NO;
+
+ return rs;
+}
+
+- (FMResultSet *)executeQuery:(NSString*)sql, ... {
+ va_list args;
+ va_start(args, sql);
+
+ id result = [self executeQuery:sql withArgumentsInArray:nil orDictionary:nil orVAList:args];
+
+ va_end(args);
+ return result;
+}
+
+- (FMResultSet *)executeQueryWithFormat:(NSString*)format, ... {
+ va_list args;
+ va_start(args, format);
+
+ NSMutableString *sql = [NSMutableString stringWithCapacity:[format length]];
+ NSMutableArray *arguments = [NSMutableArray array];
+ [self extractSQL:format argumentsList:args intoString:sql arguments:arguments];
+
+ va_end(args);
+
+ return [self executeQuery:sql withArgumentsInArray:arguments];
+}
+
+- (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)arguments {
+ return [self executeQuery:sql withArgumentsInArray:arguments orDictionary:nil orVAList:nil];
+}
+
+- (FMResultSet *)executeQuery:(NSString *)sql values:(NSArray *)values error:(NSError * __autoreleasing *)error {
+ FMResultSet *rs = [self executeQuery:sql withArgumentsInArray:values orDictionary:nil orVAList:nil];
+ if (!rs && error) {
+ *error = [self lastError];
+ }
+ return rs;
+}
+
+- (FMResultSet *)executeQuery:(NSString*)sql withVAList:(va_list)args {
+ return [self executeQuery:sql withArgumentsInArray:nil orDictionary:nil orVAList:args];
+}
+
+#pragma mark Execute updates
+
+- (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args {
+
+ if (![self databaseExists]) {
+ return NO;
+ }
+
+ if (_isExecutingStatement) {
+ [self warnInUse];
+ return NO;
+ }
+
+ _isExecutingStatement = YES;
+
+ int rc = 0x00;
+ sqlite3_stmt *pStmt = 0x00;
+ FMStatement *cachedStmt = 0x00;
+
+ if (_traceExecution && sql) {
+ NSLog(@"%@ executeUpdate: %@", self, sql);
+ }
+
+ if (_shouldCacheStatements) {
+ cachedStmt = [self cachedStatementForQuery:sql];
+ pStmt = cachedStmt ? [cachedStmt statement] : 0x00;
+ [cachedStmt reset];
+ }
+
+ if (!pStmt) {
+ rc = sqlite3_prepare_v2(_db, [sql UTF8String], -1, &pStmt, 0);
+
+ if (SQLITE_OK != rc) {
+ if (_logsErrors) {
+ NSLog(@"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]);
+ NSLog(@"DB Query: %@", sql);
+ NSLog(@"DB Path: %@", _databasePath);
+ }
+
+ if (_crashOnErrors) {
+ NSAssert(false, @"DB Error: %d \"%@\"", [self lastErrorCode], [self lastErrorMessage]);
+ abort();
+ }
+
+ sqlite3_finalize(pStmt);
+
+ if (outErr) {
+ *outErr = [self errorWithMessage:[NSString stringWithUTF8String:sqlite3_errmsg(_db)]];
+ }
+
+ _isExecutingStatement = NO;
+ return NO;
+ }
+ }
+
+ id obj;
+ int idx = 0;
+ int queryCount = sqlite3_bind_parameter_count(pStmt);
+
+ // If dictionaryArgs is passed in, that means we are using sqlite's named parameter support
+ if (dictionaryArgs) {
+
+ for (NSString *dictionaryKey in [dictionaryArgs allKeys]) {
+
+ // Prefix the key with a colon.
+ NSString *parameterName = [[NSString alloc] initWithFormat:@":%@", dictionaryKey];
+
+ if (_traceExecution) {
+ NSLog(@"%@ = %@", parameterName, [dictionaryArgs objectForKey:dictionaryKey]);
+ }
+ // Get the index for the parameter name.
+ int namedIdx = sqlite3_bind_parameter_index(pStmt, [parameterName UTF8String]);
+
+ FMDBRelease(parameterName);
+
+ if (namedIdx > 0) {
+ // Standard binding from here.
+ [self bindObject:[dictionaryArgs objectForKey:dictionaryKey] toColumn:namedIdx inStatement:pStmt];
+
+ // increment the binding count, so our check below works out
+ idx++;
+ }
+ else {
+ NSLog(@"Could not find index for %@", dictionaryKey);
+ }
+ }
+ }
+ else {
+
+ while (idx < queryCount) {
+
+ if (arrayArgs && idx < (int)[arrayArgs count]) {
+ obj = [arrayArgs objectAtIndex:(NSUInteger)idx];
+ }
+ else if (args) {
+ obj = va_arg(args, id);
+ }
+ else {
+ //We ran out of arguments
+ break;
+ }
+
+ if (_traceExecution) {
+ if ([obj isKindOfClass:[NSData class]]) {
+ NSLog(@"data: %ld bytes", (unsigned long)[(NSData*)obj length]);
+ }
+ else {
+ NSLog(@"obj: %@", obj);
+ }
+ }
+
+ idx++;
+
+ [self bindObject:obj toColumn:idx inStatement:pStmt];
+ }
+ }
+
+
+ if (idx != queryCount) {
+ NSLog(@"Error: the bind count (%d) is not correct for the # of variables in the query (%d) (%@) (executeUpdate)", idx, queryCount, sql);
+ sqlite3_finalize(pStmt);
+ _isExecutingStatement = NO;
+ return NO;
+ }
+
+ /* Call sqlite3_step() to run the virtual machine. Since the SQL being
+ ** executed is not a SELECT statement, we assume no data will be returned.
+ */
+
+ rc = sqlite3_step(pStmt);
+
+ if (SQLITE_DONE == rc) {
+ // all is well, let's return.
+ }
+ else if (SQLITE_ERROR == rc) {
+ if (_logsErrors) {
+ NSLog(@"Error calling sqlite3_step (%d: %s) SQLITE_ERROR", rc, sqlite3_errmsg(_db));
+ NSLog(@"DB Query: %@", sql);
+ }
+ }
+ else if (SQLITE_MISUSE == rc) {
+ // uh oh.
+ if (_logsErrors) {
+ NSLog(@"Error calling sqlite3_step (%d: %s) SQLITE_MISUSE", rc, sqlite3_errmsg(_db));
+ NSLog(@"DB Query: %@", sql);
+ }
+ }
+ else {
+ // wtf?
+ if (_logsErrors) {
+ NSLog(@"Unknown error calling sqlite3_step (%d: %s) eu", rc, sqlite3_errmsg(_db));
+ NSLog(@"DB Query: %@", sql);
+ }
+ }
+
+ if (rc == SQLITE_ROW) {
+ NSAssert(NO, @"A executeUpdate is being called with a query string '%@'", sql);
+ }
+
+ if (_shouldCacheStatements && !cachedStmt) {
+ cachedStmt = [[FMStatement alloc] init];
+
+ [cachedStmt setStatement:pStmt];
+
+ [self setCachedStatement:cachedStmt forQuery:sql];
+
+ FMDBRelease(cachedStmt);
+ }
+
+ int closeErrorCode;
+
+ if (cachedStmt) {
+ [cachedStmt setUseCount:[cachedStmt useCount] + 1];
+ closeErrorCode = sqlite3_reset(pStmt);
+ }
+ else {
+ /* Finalize the virtual machine. This releases all memory and other
+ ** resources allocated by the sqlite3_prepare() call above.
+ */
+ closeErrorCode = sqlite3_finalize(pStmt);
+ }
+
+ if (closeErrorCode != SQLITE_OK) {
+ if (_logsErrors) {
+ NSLog(@"Unknown error finalizing or resetting statement (%d: %s)", closeErrorCode, sqlite3_errmsg(_db));
+ NSLog(@"DB Query: %@", sql);
+ }
+ }
+
+ _isExecutingStatement = NO;
+ return (rc == SQLITE_DONE || rc == SQLITE_OK);
+}
+
+
+- (BOOL)executeUpdate:(NSString*)sql, ... {
+ va_list args;
+ va_start(args, sql);
+
+ BOOL result = [self executeUpdate:sql error:nil withArgumentsInArray:nil orDictionary:nil orVAList:args];
+
+ va_end(args);
+ return result;
+}
+
+- (BOOL)executeUpdate:(NSString*)sql withArgumentsInArray:(NSArray *)arguments {
+ return [self executeUpdate:sql error:nil withArgumentsInArray:arguments orDictionary:nil orVAList:nil];
+}
+
+- (BOOL)executeUpdate:(NSString*)sql values:(NSArray *)values error:(NSError * __autoreleasing *)error {
+ return [self executeUpdate:sql error:error withArgumentsInArray:values orDictionary:nil orVAList:nil];
+}
+
+- (BOOL)executeUpdate:(NSString*)sql withParameterDictionary:(NSDictionary *)arguments {
+ return [self executeUpdate:sql error:nil withArgumentsInArray:nil orDictionary:arguments orVAList:nil];
+}
+
+- (BOOL)executeUpdate:(NSString*)sql withVAList:(va_list)args {
+ return [self executeUpdate:sql error:nil withArgumentsInArray:nil orDictionary:nil orVAList:args];
+}
+
+- (BOOL)executeUpdateWithFormat:(NSString*)format, ... {
+ va_list args;
+ va_start(args, format);
+
+ NSMutableString *sql = [NSMutableString stringWithCapacity:[format length]];
+ NSMutableArray *arguments = [NSMutableArray array];
+
+ [self extractSQL:format argumentsList:args intoString:sql arguments:arguments];
+
+ va_end(args);
+
+ return [self executeUpdate:sql withArgumentsInArray:arguments];
+}
+
+
+int FMDBExecuteBulkSQLCallback(void *theBlockAsVoid, int columns, char **values, char **names); // shhh clang.
+int FMDBExecuteBulkSQLCallback(void *theBlockAsVoid, int columns, char **values, char **names) {
+
+ if (!theBlockAsVoid) {
+ return SQLITE_OK;
+ }
+
+ int (^execCallbackBlock)(NSDictionary *resultsDictionary) = (__bridge int (^)(NSDictionary *__strong))(theBlockAsVoid);
+
+ NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:(NSUInteger)columns];
+
+ for (NSInteger i = 0; i < columns; i++) {
+ NSString *key = [NSString stringWithUTF8String:names[i]];
+ id value = values[i] ? [NSString stringWithUTF8String:values[i]] : [NSNull null];
+ [dictionary setObject:value forKey:key];
+ }
+
+ return execCallbackBlock(dictionary);
+}
+
+- (BOOL)executeStatements:(NSString *)sql {
+ return [self executeStatements:sql withResultBlock:nil];
+}
+
+- (BOOL)executeStatements:(NSString *)sql withResultBlock:(FMDBExecuteStatementsCallbackBlock)block {
+
+ int rc;
+ char *errmsg = nil;
+
+ rc = sqlite3_exec([self sqliteHandle], [sql UTF8String], block ? FMDBExecuteBulkSQLCallback : nil, (__bridge void *)(block), &errmsg);
+
+ if (errmsg && [self logsErrors]) {
+ NSLog(@"Error inserting batch: %s", errmsg);
+ sqlite3_free(errmsg);
+ }
+
+ return (rc == SQLITE_OK);
+}
+
+- (BOOL)executeUpdate:(NSString*)sql withErrorAndBindings:(NSError**)outErr, ... {
+
+ va_list args;
+ va_start(args, outErr);
+
+ BOOL result = [self executeUpdate:sql error:outErr withArgumentsInArray:nil orDictionary:nil orVAList:args];
+
+ va_end(args);
+ return result;
+}
+
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
+- (BOOL)update:(NSString*)sql withErrorAndBindings:(NSError**)outErr, ... {
+ va_list args;
+ va_start(args, outErr);
+
+ BOOL result = [self executeUpdate:sql error:outErr withArgumentsInArray:nil orDictionary:nil orVAList:args];
+
+ va_end(args);
+ return result;
+}
+
+#pragma clang diagnostic pop
+
+#pragma mark Transactions
+
+- (BOOL)rollback {
+ BOOL b = [self executeUpdate:@"rollback transaction"];
+
+ if (b) {
+ _inTransaction = NO;
+ }
+
+ return b;
+}
+
+- (BOOL)commit {
+ BOOL b = [self executeUpdate:@"commit transaction"];
+
+ if (b) {
+ _inTransaction = NO;
+ }
+
+ return b;
+}
+
+- (BOOL)beginDeferredTransaction {
+
+ BOOL b = [self executeUpdate:@"begin deferred transaction"];
+ if (b) {
+ _inTransaction = YES;
+ }
+
+ return b;
+}
+
+- (BOOL)beginTransaction {
+
+ BOOL b = [self executeUpdate:@"begin exclusive transaction"];
+ if (b) {
+ _inTransaction = YES;
+ }
+
+ return b;
+}
+
+- (BOOL)inTransaction {
+ return _inTransaction;
+}
+
+static NSString *FMDBEscapeSavePointName(NSString *savepointName) {
+ return [savepointName stringByReplacingOccurrencesOfString:@"'" withString:@"''"];
+}
+
+- (BOOL)startSavePointWithName:(NSString*)name error:(NSError**)outErr {
+#if SQLITE_VERSION_NUMBER >= 3007000
+ NSParameterAssert(name);
+
+ NSString *sql = [NSString stringWithFormat:@"savepoint '%@';", FMDBEscapeSavePointName(name)];
+
+ if (![self executeUpdate:sql]) {
+
+ if (outErr) {
+ *outErr = [self lastError];
+ }
+
+ return NO;
+ }
+
+ return YES;
+#else
+ NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+ return NO;
+#endif
+}
+
+- (BOOL)releaseSavePointWithName:(NSString*)name error:(NSError**)outErr {
+#if SQLITE_VERSION_NUMBER >= 3007000
+ NSParameterAssert(name);
+
+ NSString *sql = [NSString stringWithFormat:@"release savepoint '%@';", FMDBEscapeSavePointName(name)];
+ BOOL worked = [self executeUpdate:sql];
+
+ if (!worked && outErr) {
+ *outErr = [self lastError];
+ }
+
+ return worked;
+#else
+ NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+ return NO;
+#endif
+}
+
+- (BOOL)rollbackToSavePointWithName:(NSString*)name error:(NSError**)outErr {
+#if SQLITE_VERSION_NUMBER >= 3007000
+ NSParameterAssert(name);
+
+ NSString *sql = [NSString stringWithFormat:@"rollback transaction to savepoint '%@';", FMDBEscapeSavePointName(name)];
+ BOOL worked = [self executeUpdate:sql];
+
+ if (!worked && outErr) {
+ *outErr = [self lastError];
+ }
+
+ return worked;
+#else
+ NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+ return NO;
+#endif
+}
+
+- (NSError*)inSavePoint:(void (^)(BOOL *rollback))block {
+#if SQLITE_VERSION_NUMBER >= 3007000
+ static unsigned long savePointIdx = 0;
+
+ NSString *name = [NSString stringWithFormat:@"dbSavePoint%ld", savePointIdx++];
+
+ BOOL shouldRollback = NO;
+
+ NSError *err = 0x00;
+
+ if (![self startSavePointWithName:name error:&err]) {
+ return err;
+ }
+
+ if (block) {
+ block(&shouldRollback);
+ }
+
+ if (shouldRollback) {
+ // We need to rollback and release this savepoint to remove it
+ [self rollbackToSavePointWithName:name error:&err];
+ }
+ [self releaseSavePointWithName:name error:&err];
+
+ return err;
+#else
+ NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+ return [NSError errorWithDomain:@"FMDatabase" code:0 userInfo:@{NSLocalizedDescriptionKey : errorMessage}];
+#endif
+}
+
+
+#pragma mark Cache statements
+
+- (BOOL)shouldCacheStatements {
+ return _shouldCacheStatements;
+}
+
+- (void)setShouldCacheStatements:(BOOL)value {
+
+ _shouldCacheStatements = value;
+
+ if (_shouldCacheStatements && !_cachedStatements) {
+ [self setCachedStatements:[NSMutableDictionary dictionary]];
+ }
+
+ if (!_shouldCacheStatements) {
+ [self setCachedStatements:nil];
+ }
+}
+
+#pragma mark Callback function
+
+void FMDBBlockSQLiteCallBackFunction(sqlite3_context *context, int argc, sqlite3_value **argv); // -Wmissing-prototypes
+void FMDBBlockSQLiteCallBackFunction(sqlite3_context *context, int argc, sqlite3_value **argv) {
+#if ! __has_feature(objc_arc)
+ void (^block)(sqlite3_context *context, int argc, sqlite3_value **argv) = (id)sqlite3_user_data(context);
+#else
+ void (^block)(sqlite3_context *context, int argc, sqlite3_value **argv) = (__bridge id)sqlite3_user_data(context);
+#endif
+ if (block) {
+ block(context, argc, argv);
+ }
+}
+
+
+- (void)makeFunctionNamed:(NSString*)name maximumArguments:(int)count withBlock:(void (^)(void *context, int argc, void **argv))block {
+
+ if (!_openFunctions) {
+ _openFunctions = [NSMutableSet new];
+ }
+
+ id b = FMDBReturnAutoreleased([block copy]);
+
+ [_openFunctions addObject:b];
+
+ /* I tried adding custom functions to release the block when the connection is destroyed- but they seemed to never be called, so we use _openFunctions to store the values instead. */
+#if ! __has_feature(objc_arc)
+ sqlite3_create_function([self sqliteHandle], [name UTF8String], count, SQLITE_UTF8, (void*)b, &FMDBBlockSQLiteCallBackFunction, 0x00, 0x00);
+#else
+ sqlite3_create_function([self sqliteHandle], [name UTF8String], count, SQLITE_UTF8, (__bridge void*)b, &FMDBBlockSQLiteCallBackFunction, 0x00, 0x00);
+#endif
+}
+
+@end
+
+
+
+@implementation FMStatement
+@synthesize statement=_statement;
+@synthesize query=_query;
+@synthesize useCount=_useCount;
+@synthesize inUse=_inUse;
+
+- (void)finalize {
+ [self close];
+ [super finalize];
+}
+
+- (void)dealloc {
+ [self close];
+ FMDBRelease(_query);
+#if ! __has_feature(objc_arc)
+ [super dealloc];
+#endif
+}
+
+- (void)close {
+ if (_statement) {
+ sqlite3_finalize(_statement);
+ _statement = 0x00;
+ }
+
+ _inUse = NO;
+}
+
+- (void)reset {
+ if (_statement) {
+ sqlite3_reset(_statement);
+ }
+
+ _inUse = NO;
+}
+
+- (NSString*)description {
+ return [NSString stringWithFormat:@"%@ %ld hit(s) for query %@", [super description], _useCount, _query];
+}
+
+
+@end
+
diff --git a/ios/Pods/FMDB/src/fmdb/FMDatabaseAdditions.h b/ios/Pods/FMDB/src/fmdb/FMDatabaseAdditions.h
new file mode 100644
index 0000000..9dd0b62
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDatabaseAdditions.h
@@ -0,0 +1,278 @@
+//
+// FMDatabaseAdditions.h
+// fmdb
+//
+// Created by August Mueller on 10/30/05.
+// Copyright 2005 Flying Meat Inc.. All rights reserved.
+//
+
+#import
+#import "FMDatabase.h"
+
+
+/** Category of additions for `` class.
+
+ ### See also
+
+ - ``
+ */
+
+@interface FMDatabase (FMDatabaseAdditions)
+
+///----------------------------------------
+/// @name Return results of SQL to variable
+///----------------------------------------
+
+/** Return `int` value for query
+
+ @param query The SQL query to be performed.
+ @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
+
+ @return `int` value.
+
+ @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
+ */
+
+- (int)intForQuery:(NSString*)query, ...;
+
+/** Return `long` value for query
+
+ @param query The SQL query to be performed.
+ @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
+
+ @return `long` value.
+
+ @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
+ */
+
+- (long)longForQuery:(NSString*)query, ...;
+
+/** Return `BOOL` value for query
+
+ @param query The SQL query to be performed.
+ @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
+
+ @return `BOOL` value.
+
+ @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
+ */
+
+- (BOOL)boolForQuery:(NSString*)query, ...;
+
+/** Return `double` value for query
+
+ @param query The SQL query to be performed.
+ @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
+
+ @return `double` value.
+
+ @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
+ */
+
+- (double)doubleForQuery:(NSString*)query, ...;
+
+/** Return `NSString` value for query
+
+ @param query The SQL query to be performed.
+ @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
+
+ @return `NSString` value.
+
+ @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
+ */
+
+- (NSString*)stringForQuery:(NSString*)query, ...;
+
+/** Return `NSData` value for query
+
+ @param query The SQL query to be performed.
+ @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
+
+ @return `NSData` value.
+
+ @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
+ */
+
+- (NSData*)dataForQuery:(NSString*)query, ...;
+
+/** Return `NSDate` value for query
+
+ @param query The SQL query to be performed.
+ @param ... A list of parameters that will be bound to the `?` placeholders in the SQL query.
+
+ @return `NSDate` value.
+
+ @note To use this method from Swift, you must include `FMDatabaseAdditionsVariadic.swift` in your project.
+ */
+
+- (NSDate*)dateForQuery:(NSString*)query, ...;
+
+
+// Notice that there's no dataNoCopyForQuery:.
+// That would be a bad idea, because we close out the result set, and then what
+// happens to the data that we just didn't copy? Who knows, not I.
+
+
+///--------------------------------
+/// @name Schema related operations
+///--------------------------------
+
+/** Does table exist in database?
+
+ @param tableName The name of the table being looked for.
+
+ @return `YES` if table found; `NO` if not found.
+ */
+
+- (BOOL)tableExists:(NSString*)tableName;
+
+/** The schema of the database.
+
+ This will be the schema for the entire database. For each entity, each row of the result set will include the following fields:
+
+ - `type` - The type of entity (e.g. table, index, view, or trigger)
+ - `name` - The name of the object
+ - `tbl_name` - The name of the table to which the object references
+ - `rootpage` - The page number of the root b-tree page for tables and indices
+ - `sql` - The SQL that created the entity
+
+ @return `FMResultSet` of schema; `nil` on error.
+
+ @see [SQLite File Format](http://www.sqlite.org/fileformat.html)
+ */
+
+- (FMResultSet*)getSchema;
+
+/** The schema of the database.
+
+ This will be the schema for a particular table as report by SQLite `PRAGMA`, for example:
+
+ PRAGMA table_info('employees')
+
+ This will report:
+
+ - `cid` - The column ID number
+ - `name` - The name of the column
+ - `type` - The data type specified for the column
+ - `notnull` - whether the field is defined as NOT NULL (i.e. values required)
+ - `dflt_value` - The default value for the column
+ - `pk` - Whether the field is part of the primary key of the table
+
+ @param tableName The name of the table for whom the schema will be returned.
+
+ @return `FMResultSet` of schema; `nil` on error.
+
+ @see [table_info](http://www.sqlite.org/pragma.html#pragma_table_info)
+ */
+
+- (FMResultSet*)getTableSchema:(NSString*)tableName;
+
+/** Test to see if particular column exists for particular table in database
+
+ @param columnName The name of the column.
+
+ @param tableName The name of the table.
+
+ @return `YES` if column exists in table in question; `NO` otherwise.
+ */
+
+- (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName;
+
+/** Test to see if particular column exists for particular table in database
+
+ @param columnName The name of the column.
+
+ @param tableName The name of the table.
+
+ @return `YES` if column exists in table in question; `NO` otherwise.
+
+ @see columnExists:inTableWithName:
+
+ @warning Deprecated - use `` instead.
+ */
+
+- (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName __attribute__ ((deprecated));
+
+
+/** Validate SQL statement
+
+ This validates SQL statement by performing `sqlite3_prepare_v2`, but not returning the results, but instead immediately calling `sqlite3_finalize`.
+
+ @param sql The SQL statement being validated.
+
+ @param error This is a pointer to a `NSError` object that will receive the autoreleased `NSError` object if there was any error. If this is `nil`, no `NSError` result will be returned.
+
+ @return `YES` if validation succeeded without incident; `NO` otherwise.
+
+ */
+
+- (BOOL)validateSQL:(NSString*)sql error:(NSError**)error;
+
+
+///-----------------------------------
+/// @name Application identifier tasks
+///-----------------------------------
+
+/** Retrieve application ID
+
+ @return The `uint32_t` numeric value of the application ID.
+
+ @see setApplicationID:
+ */
+
+- (uint32_t)applicationID;
+
+/** Set the application ID
+
+ @param appID The `uint32_t` numeric value of the application ID.
+
+ @see applicationID
+ */
+
+- (void)setApplicationID:(uint32_t)appID;
+
+#if TARGET_OS_MAC && !TARGET_OS_IPHONE
+/** Retrieve application ID string
+
+ @return The `NSString` value of the application ID.
+
+ @see setApplicationIDString:
+ */
+
+
+- (NSString*)applicationIDString;
+
+/** Set the application ID string
+
+ @param string The `NSString` value of the application ID.
+
+ @see applicationIDString
+ */
+
+- (void)setApplicationIDString:(NSString*)string;
+
+#endif
+
+///-----------------------------------
+/// @name user version identifier tasks
+///-----------------------------------
+
+/** Retrieve user version
+
+ @return The `uint32_t` numeric value of the user version.
+
+ @see setUserVersion:
+ */
+
+- (uint32_t)userVersion;
+
+/** Set the user-version
+
+ @param version The `uint32_t` numeric value of the user version.
+
+ @see userVersion
+ */
+
+- (void)setUserVersion:(uint32_t)version;
+
+@end
diff --git a/ios/Pods/FMDB/src/fmdb/FMDatabaseAdditions.m b/ios/Pods/FMDB/src/fmdb/FMDatabaseAdditions.m
new file mode 100644
index 0000000..61fa747
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDatabaseAdditions.m
@@ -0,0 +1,246 @@
+//
+// FMDatabaseAdditions.m
+// fmdb
+//
+// Created by August Mueller on 10/30/05.
+// Copyright 2005 Flying Meat Inc.. All rights reserved.
+//
+
+#import "FMDatabase.h"
+#import "FMDatabaseAdditions.h"
+#import "TargetConditionals.h"
+
+#if FMDB_SQLITE_STANDALONE
+#import
+#else
+#import
+#endif
+
+@interface FMDatabase (PrivateStuff)
+- (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arrayArgs orDictionary:(NSDictionary *)dictionaryArgs orVAList:(va_list)args;
+@end
+
+@implementation FMDatabase (FMDatabaseAdditions)
+
+#define RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(type, sel) \
+va_list args; \
+va_start(args, query); \
+FMResultSet *resultSet = [self executeQuery:query withArgumentsInArray:0x00 orDictionary:0x00 orVAList:args]; \
+va_end(args); \
+if (![resultSet next]) { return (type)0; } \
+type ret = [resultSet sel:0]; \
+[resultSet close]; \
+[resultSet setParentDB:nil]; \
+return ret;
+
+
+- (NSString*)stringForQuery:(NSString*)query, ... {
+ RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSString *, stringForColumnIndex);
+}
+
+- (int)intForQuery:(NSString*)query, ... {
+ RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(int, intForColumnIndex);
+}
+
+- (long)longForQuery:(NSString*)query, ... {
+ RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(long, longForColumnIndex);
+}
+
+- (BOOL)boolForQuery:(NSString*)query, ... {
+ RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(BOOL, boolForColumnIndex);
+}
+
+- (double)doubleForQuery:(NSString*)query, ... {
+ RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(double, doubleForColumnIndex);
+}
+
+- (NSData*)dataForQuery:(NSString*)query, ... {
+ RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSData *, dataForColumnIndex);
+}
+
+- (NSDate*)dateForQuery:(NSString*)query, ... {
+ RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSDate *, dateForColumnIndex);
+}
+
+
+- (BOOL)tableExists:(NSString*)tableName {
+
+ tableName = [tableName lowercaseString];
+
+ FMResultSet *rs = [self executeQuery:@"select [sql] from sqlite_master where [type] = 'table' and lower(name) = ?", tableName];
+
+ //if at least one next exists, table exists
+ BOOL returnBool = [rs next];
+
+ //close and free object
+ [rs close];
+
+ return returnBool;
+}
+
+/*
+ get table with list of tables: result colums: type[STRING], name[STRING],tbl_name[STRING],rootpage[INTEGER],sql[STRING]
+ check if table exist in database (patch from OZLB)
+*/
+- (FMResultSet*)getSchema {
+
+ //result colums: type[STRING], name[STRING],tbl_name[STRING],rootpage[INTEGER],sql[STRING]
+ FMResultSet *rs = [self executeQuery:@"SELECT type, name, tbl_name, rootpage, sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE type != 'meta' AND name NOT LIKE 'sqlite_%' ORDER BY tbl_name, type DESC, name"];
+
+ return rs;
+}
+
+/*
+ get table schema: result colums: cid[INTEGER], name,type [STRING], notnull[INTEGER], dflt_value[],pk[INTEGER]
+*/
+- (FMResultSet*)getTableSchema:(NSString*)tableName {
+
+ //result colums: cid[INTEGER], name,type [STRING], notnull[INTEGER], dflt_value[],pk[INTEGER]
+ FMResultSet *rs = [self executeQuery:[NSString stringWithFormat: @"pragma table_info('%@')", tableName]];
+
+ return rs;
+}
+
+- (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName {
+
+ BOOL returnBool = NO;
+
+ tableName = [tableName lowercaseString];
+ columnName = [columnName lowercaseString];
+
+ FMResultSet *rs = [self getTableSchema:tableName];
+
+ //check if column is present in table schema
+ while ([rs next]) {
+ if ([[[rs stringForColumn:@"name"] lowercaseString] isEqualToString:columnName]) {
+ returnBool = YES;
+ break;
+ }
+ }
+
+ //If this is not done FMDatabase instance stays out of pool
+ [rs close];
+
+ return returnBool;
+}
+
+
+
+- (uint32_t)applicationID {
+#if SQLITE_VERSION_NUMBER >= 3007017
+ uint32_t r = 0;
+
+ FMResultSet *rs = [self executeQuery:@"pragma application_id"];
+
+ if ([rs next]) {
+ r = (uint32_t)[rs longLongIntForColumnIndex:0];
+ }
+
+ [rs close];
+
+ return r;
+#else
+ NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+ return 0;
+#endif
+}
+
+- (void)setApplicationID:(uint32_t)appID {
+#if SQLITE_VERSION_NUMBER >= 3007017
+ NSString *query = [NSString stringWithFormat:@"pragma application_id=%d", appID];
+ FMResultSet *rs = [self executeQuery:query];
+ [rs next];
+ [rs close];
+#else
+ NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+#endif
+}
+
+
+#if TARGET_OS_MAC && !TARGET_OS_IPHONE
+
+- (NSString*)applicationIDString {
+#if SQLITE_VERSION_NUMBER >= 3007017
+ NSString *s = NSFileTypeForHFSTypeCode([self applicationID]);
+
+ assert([s length] == 6);
+
+ s = [s substringWithRange:NSMakeRange(1, 4)];
+
+
+ return s;
+#else
+ NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+ return nil;
+#endif
+}
+
+- (void)setApplicationIDString:(NSString*)s {
+#if SQLITE_VERSION_NUMBER >= 3007017
+ if ([s length] != 4) {
+ NSLog(@"setApplicationIDString: string passed is not exactly 4 chars long. (was %ld)", [s length]);
+ }
+
+ [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])];
+#else
+ NSString *errorMessage = NSLocalizedString(@"Application ID functions require SQLite 3.7.17", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+#endif
+}
+
+#endif
+
+- (uint32_t)userVersion {
+ uint32_t r = 0;
+
+ FMResultSet *rs = [self executeQuery:@"pragma user_version"];
+
+ if ([rs next]) {
+ r = (uint32_t)[rs longLongIntForColumnIndex:0];
+ }
+
+ [rs close];
+ return r;
+}
+
+- (void)setUserVersion:(uint32_t)version {
+ NSString *query = [NSString stringWithFormat:@"pragma user_version = %d", version];
+ FMResultSet *rs = [self executeQuery:query];
+ [rs next];
+ [rs close];
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
+
+- (BOOL)columnExists:(NSString*)tableName columnName:(NSString*)columnName __attribute__ ((deprecated)) {
+ return [self columnExists:columnName inTableWithName:tableName];
+}
+
+#pragma clang diagnostic pop
+
+
+- (BOOL)validateSQL:(NSString*)sql error:(NSError**)error {
+ sqlite3_stmt *pStmt = NULL;
+ BOOL validationSucceeded = YES;
+
+ int rc = sqlite3_prepare_v2(_db, [sql UTF8String], -1, &pStmt, 0);
+ if (rc != SQLITE_OK) {
+ validationSucceeded = NO;
+ if (error) {
+ *error = [NSError errorWithDomain:NSCocoaErrorDomain
+ code:[self lastErrorCode]
+ userInfo:[NSDictionary dictionaryWithObject:[self lastErrorMessage]
+ forKey:NSLocalizedDescriptionKey]];
+ }
+ }
+
+ sqlite3_finalize(pStmt);
+
+ return validationSucceeded;
+}
+
+@end
diff --git a/ios/Pods/FMDB/src/fmdb/FMDatabasePool.h b/ios/Pods/FMDB/src/fmdb/FMDatabasePool.h
new file mode 100644
index 0000000..1915858
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDatabasePool.h
@@ -0,0 +1,200 @@
+//
+// FMDatabasePool.h
+// fmdb
+//
+// Created by August Mueller on 6/22/11.
+// Copyright 2011 Flying Meat Inc. All rights reserved.
+//
+
+#import
+
+@class FMDatabase;
+
+/** Pool of `` objects.
+
+ ### See also
+
+ - ``
+ - ``
+
+ @warning Before using `FMDatabasePool`, please consider using `` instead.
+
+ If you really really really know what you're doing and `FMDatabasePool` is what
+ you really really need (ie, you're using a read only database), OK you can use
+ it. But just be careful not to deadlock!
+
+ For an example on deadlocking, search for:
+ `ONLY_USE_THE_POOL_IF_YOU_ARE_DOING_READS_OTHERWISE_YOULL_DEADLOCK_USE_FMDATABASEQUEUE_INSTEAD`
+ in the main.m file.
+ */
+
+@interface FMDatabasePool : NSObject {
+ NSString *_path;
+
+ dispatch_queue_t _lockQueue;
+
+ NSMutableArray *_databaseInPool;
+ NSMutableArray *_databaseOutPool;
+
+ __unsafe_unretained id _delegate;
+
+ NSUInteger _maximumNumberOfDatabasesToCreate;
+ int _openFlags;
+}
+
+/** Database path */
+
+@property (atomic, retain) NSString *path;
+
+/** Delegate object */
+
+@property (atomic, assign) id delegate;
+
+/** Maximum number of databases to create */
+
+@property (atomic, assign) NSUInteger maximumNumberOfDatabasesToCreate;
+
+/** Open flags */
+
+@property (atomic, readonly) int openFlags;
+
+
+///---------------------
+/// @name Initialization
+///---------------------
+
+/** Create pool using path.
+
+ @param aPath The file path of the database.
+
+ @return The `FMDatabasePool` object. `nil` on error.
+ */
+
++ (instancetype)databasePoolWithPath:(NSString*)aPath;
+
+/** Create pool using path and specified flags
+
+ @param aPath The file path of the database.
+ @param openFlags Flags passed to the openWithFlags method of the database
+
+ @return The `FMDatabasePool` object. `nil` on error.
+ */
+
++ (instancetype)databasePoolWithPath:(NSString*)aPath flags:(int)openFlags;
+
+/** Create pool using path.
+
+ @param aPath The file path of the database.
+
+ @return The `FMDatabasePool` object. `nil` on error.
+ */
+
+- (instancetype)initWithPath:(NSString*)aPath;
+
+/** Create pool using path and specified flags.
+
+ @param aPath The file path of the database.
+ @param openFlags Flags passed to the openWithFlags method of the database
+
+ @return The `FMDatabasePool` object. `nil` on error.
+ */
+
+- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags;
+
+///------------------------------------------------
+/// @name Keeping track of checked in/out databases
+///------------------------------------------------
+
+/** Number of checked-in databases in pool
+
+ @returns Number of databases
+ */
+
+- (NSUInteger)countOfCheckedInDatabases;
+
+/** Number of checked-out databases in pool
+
+ @returns Number of databases
+ */
+
+- (NSUInteger)countOfCheckedOutDatabases;
+
+/** Total number of databases in pool
+
+ @returns Number of databases
+ */
+
+- (NSUInteger)countOfOpenDatabases;
+
+/** Release all databases in pool */
+
+- (void)releaseAllDatabases;
+
+///------------------------------------------
+/// @name Perform database operations in pool
+///------------------------------------------
+
+/** Synchronously perform database operations in pool.
+
+ @param block The code to be run on the `FMDatabasePool` pool.
+ */
+
+- (void)inDatabase:(void (^)(FMDatabase *db))block;
+
+/** Synchronously perform database operations in pool using transaction.
+
+ @param block The code to be run on the `FMDatabasePool` pool.
+ */
+
+- (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
+
+/** Synchronously perform database operations in pool using deferred transaction.
+
+ @param block The code to be run on the `FMDatabasePool` pool.
+ */
+
+- (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
+
+/** Synchronously perform database operations in pool using save point.
+
+ @param block The code to be run on the `FMDatabasePool` pool.
+
+ @return `NSError` object if error; `nil` if successful.
+
+ @warning You can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock. If you need to nest, use `<[FMDatabase startSavePointWithName:error:]>` instead.
+*/
+
+- (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block;
+
+@end
+
+
+/** FMDatabasePool delegate category
+
+ This is a category that defines the protocol for the FMDatabasePool delegate
+ */
+
+@interface NSObject (FMDatabasePoolDelegate)
+
+/** Asks the delegate whether database should be added to the pool.
+
+ @param pool The `FMDatabasePool` object.
+ @param database The `FMDatabase` object.
+
+ @return `YES` if it should add database to pool; `NO` if not.
+
+ */
+
+- (BOOL)databasePool:(FMDatabasePool*)pool shouldAddDatabaseToPool:(FMDatabase*)database;
+
+/** Tells the delegate that database was added to the pool.
+
+ @param pool The `FMDatabasePool` object.
+ @param database The `FMDatabase` object.
+
+ */
+
+- (void)databasePool:(FMDatabasePool*)pool didAddDatabase:(FMDatabase*)database;
+
+@end
+
diff --git a/ios/Pods/FMDB/src/fmdb/FMDatabasePool.m b/ios/Pods/FMDB/src/fmdb/FMDatabasePool.m
new file mode 100644
index 0000000..e8e52cb
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDatabasePool.m
@@ -0,0 +1,283 @@
+//
+// FMDatabasePool.m
+// fmdb
+//
+// Created by August Mueller on 6/22/11.
+// Copyright 2011 Flying Meat Inc. All rights reserved.
+//
+
+#if FMDB_SQLITE_STANDALONE
+#import
+#else
+#import
+#endif
+
+#import "FMDatabasePool.h"
+#import "FMDatabase.h"
+
+@interface FMDatabasePool()
+
+- (void)pushDatabaseBackInPool:(FMDatabase*)db;
+- (FMDatabase*)db;
+
+@end
+
+
+@implementation FMDatabasePool
+@synthesize path=_path;
+@synthesize delegate=_delegate;
+@synthesize maximumNumberOfDatabasesToCreate=_maximumNumberOfDatabasesToCreate;
+@synthesize openFlags=_openFlags;
+
+
++ (instancetype)databasePoolWithPath:(NSString*)aPath {
+ return FMDBReturnAutoreleased([[self alloc] initWithPath:aPath]);
+}
+
++ (instancetype)databasePoolWithPath:(NSString*)aPath flags:(int)openFlags {
+ return FMDBReturnAutoreleased([[self alloc] initWithPath:aPath flags:openFlags]);
+}
+
+- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags {
+
+ self = [super init];
+
+ if (self != nil) {
+ _path = [aPath copy];
+ _lockQueue = dispatch_queue_create([[NSString stringWithFormat:@"fmdb.%@", self] UTF8String], NULL);
+ _databaseInPool = FMDBReturnRetained([NSMutableArray array]);
+ _databaseOutPool = FMDBReturnRetained([NSMutableArray array]);
+ _openFlags = openFlags;
+ }
+
+ return self;
+}
+
+- (instancetype)initWithPath:(NSString*)aPath
+{
+ // default flags for sqlite3_open
+ return [self initWithPath:aPath flags:SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE];
+}
+
+- (instancetype)init {
+ return [self initWithPath:nil];
+}
+
+
+- (void)dealloc {
+
+ _delegate = 0x00;
+ FMDBRelease(_path);
+ FMDBRelease(_databaseInPool);
+ FMDBRelease(_databaseOutPool);
+
+ if (_lockQueue) {
+ FMDBDispatchQueueRelease(_lockQueue);
+ _lockQueue = 0x00;
+ }
+#if ! __has_feature(objc_arc)
+ [super dealloc];
+#endif
+}
+
+
+- (void)executeLocked:(void (^)(void))aBlock {
+ dispatch_sync(_lockQueue, aBlock);
+}
+
+- (void)pushDatabaseBackInPool:(FMDatabase*)db {
+
+ if (!db) { // db can be null if we set an upper bound on the # of databases to create.
+ return;
+ }
+
+ [self executeLocked:^() {
+
+ if ([self->_databaseInPool containsObject:db]) {
+ [[NSException exceptionWithName:@"Database already in pool" reason:@"The FMDatabase being put back into the pool is already present in the pool" userInfo:nil] raise];
+ }
+
+ [self->_databaseInPool addObject:db];
+ [self->_databaseOutPool removeObject:db];
+
+ }];
+}
+
+- (FMDatabase*)db {
+
+ __block FMDatabase *db;
+
+
+ [self executeLocked:^() {
+ db = [self->_databaseInPool lastObject];
+
+ BOOL shouldNotifyDelegate = NO;
+
+ if (db) {
+ [self->_databaseOutPool addObject:db];
+ [self->_databaseInPool removeLastObject];
+ }
+ else {
+
+ if (self->_maximumNumberOfDatabasesToCreate) {
+ NSUInteger currentCount = [self->_databaseOutPool count] + [self->_databaseInPool count];
+
+ if (currentCount >= self->_maximumNumberOfDatabasesToCreate) {
+ NSLog(@"Maximum number of databases (%ld) has already been reached!", (long)currentCount);
+ return;
+ }
+ }
+
+ db = [FMDatabase databaseWithPath:self->_path];
+ shouldNotifyDelegate = YES;
+ }
+
+ //This ensures that the db is opened before returning
+#if SQLITE_VERSION_NUMBER >= 3005000
+ BOOL success = [db openWithFlags:self->_openFlags];
+#else
+ BOOL success = [db open];
+#endif
+ if (success) {
+ if ([self->_delegate respondsToSelector:@selector(databasePool:shouldAddDatabaseToPool:)] && ![self->_delegate databasePool:self shouldAddDatabaseToPool:db]) {
+ [db close];
+ db = 0x00;
+ }
+ else {
+ //It should not get added in the pool twice if lastObject was found
+ if (![self->_databaseOutPool containsObject:db]) {
+ [self->_databaseOutPool addObject:db];
+
+ if (shouldNotifyDelegate && [self->_delegate respondsToSelector:@selector(databasePool:didAddDatabase:)]) {
+ [self->_delegate databasePool:self didAddDatabase:db];
+ }
+ }
+ }
+ }
+ else {
+ NSLog(@"Could not open up the database at path %@", self->_path);
+ db = 0x00;
+ }
+ }];
+
+ return db;
+}
+
+- (NSUInteger)countOfCheckedInDatabases {
+
+ __block NSUInteger count;
+
+ [self executeLocked:^() {
+ count = [self->_databaseInPool count];
+ }];
+
+ return count;
+}
+
+- (NSUInteger)countOfCheckedOutDatabases {
+
+ __block NSUInteger count;
+
+ [self executeLocked:^() {
+ count = [self->_databaseOutPool count];
+ }];
+
+ return count;
+}
+
+- (NSUInteger)countOfOpenDatabases {
+ __block NSUInteger count;
+
+ [self executeLocked:^() {
+ count = [self->_databaseOutPool count] + [self->_databaseInPool count];
+ }];
+
+ return count;
+}
+
+- (void)releaseAllDatabases {
+ [self executeLocked:^() {
+ [self->_databaseOutPool removeAllObjects];
+ [self->_databaseInPool removeAllObjects];
+ }];
+}
+
+- (void)inDatabase:(void (^)(FMDatabase *db))block {
+
+ FMDatabase *db = [self db];
+
+ block(db);
+
+ [self pushDatabaseBackInPool:db];
+}
+
+- (void)beginTransaction:(BOOL)useDeferred withBlock:(void (^)(FMDatabase *db, BOOL *rollback))block {
+
+ BOOL shouldRollback = NO;
+
+ FMDatabase *db = [self db];
+
+ if (useDeferred) {
+ [db beginDeferredTransaction];
+ }
+ else {
+ [db beginTransaction];
+ }
+
+
+ block(db, &shouldRollback);
+
+ if (shouldRollback) {
+ [db rollback];
+ }
+ else {
+ [db commit];
+ }
+
+ [self pushDatabaseBackInPool:db];
+}
+
+- (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
+ [self beginTransaction:YES withBlock:block];
+}
+
+- (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
+ [self beginTransaction:NO withBlock:block];
+}
+
+- (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
+#if SQLITE_VERSION_NUMBER >= 3007000
+ static unsigned long savePointIdx = 0;
+
+ NSString *name = [NSString stringWithFormat:@"savePoint%ld", savePointIdx++];
+
+ BOOL shouldRollback = NO;
+
+ FMDatabase *db = [self db];
+
+ NSError *err = 0x00;
+
+ if (![db startSavePointWithName:name error:&err]) {
+ [self pushDatabaseBackInPool:db];
+ return err;
+ }
+
+ block(db, &shouldRollback);
+
+ if (shouldRollback) {
+ // We need to rollback and release this savepoint to remove it
+ [db rollbackToSavePointWithName:name error:&err];
+ }
+ [db releaseSavePointWithName:name error:&err];
+
+ [self pushDatabaseBackInPool:db];
+
+ return err;
+#else
+ NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+ return [NSError errorWithDomain:@"FMDatabase" code:0 userInfo:@{NSLocalizedDescriptionKey : errorMessage}];
+#endif
+}
+
+@end
diff --git a/ios/Pods/FMDB/src/fmdb/FMDatabaseQueue.h b/ios/Pods/FMDB/src/fmdb/FMDatabaseQueue.h
new file mode 100644
index 0000000..ae45b65
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDatabaseQueue.h
@@ -0,0 +1,182 @@
+//
+// FMDatabaseQueue.h
+// fmdb
+//
+// Created by August Mueller on 6/22/11.
+// Copyright 2011 Flying Meat Inc. All rights reserved.
+//
+
+#import
+
+@class FMDatabase;
+
+/** To perform queries and updates on multiple threads, you'll want to use `FMDatabaseQueue`.
+
+ Using a single instance of `` from multiple threads at once is a bad idea. It has always been OK to make a `` object *per thread*. Just don't share a single instance across threads, and definitely not across multiple threads at the same time.
+
+ Instead, use `FMDatabaseQueue`. Here's how to use it:
+
+ First, make your queue.
+
+ FMDatabaseQueue *queue = [FMDatabaseQueue databaseQueueWithPath:aPath];
+
+ Then use it like so:
+
+ [queue inDatabase:^(FMDatabase *db) {
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:1]];
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:2]];
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:3]];
+
+ FMResultSet *rs = [db executeQuery:@"select * from foo"];
+ while ([rs next]) {
+ //…
+ }
+ }];
+
+ An easy way to wrap things up in a transaction can be done like this:
+
+ [queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:1]];
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:2]];
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:3]];
+
+ if (whoopsSomethingWrongHappened) {
+ *rollback = YES;
+ return;
+ }
+ // etc…
+ [db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:4]];
+ }];
+
+ `FMDatabaseQueue` will run the blocks on a serialized queue (hence the name of the class). So if you call `FMDatabaseQueue`'s methods from multiple threads at the same time, they will be executed in the order they are received. This way queries and updates won't step on each other's toes, and every one is happy.
+
+ ### See also
+
+ - ``
+
+ @warning Do not instantiate a single `` object and use it across multiple threads. Use `FMDatabaseQueue` instead.
+
+ @warning The calls to `FMDatabaseQueue`'s methods are blocking. So even though you are passing along blocks, they will **not** be run on another thread.
+
+ */
+
+@interface FMDatabaseQueue : NSObject {
+ NSString *_path;
+ dispatch_queue_t _queue;
+ FMDatabase *_db;
+ int _openFlags;
+}
+
+/** Path of database */
+
+@property (atomic, retain) NSString *path;
+
+/** Open flags */
+
+@property (atomic, readonly) int openFlags;
+
+///----------------------------------------------------
+/// @name Initialization, opening, and closing of queue
+///----------------------------------------------------
+
+/** Create queue using path.
+
+ @param aPath The file path of the database.
+
+ @return The `FMDatabaseQueue` object. `nil` on error.
+ */
+
++ (instancetype)databaseQueueWithPath:(NSString*)aPath;
+
+/** Create queue using path and specified flags.
+
+ @param aPath The file path of the database.
+ @param openFlags Flags passed to the openWithFlags method of the database
+
+ @return The `FMDatabaseQueue` object. `nil` on error.
+ */
++ (instancetype)databaseQueueWithPath:(NSString*)aPath flags:(int)openFlags;
+
+/** Create queue using path.
+
+ @param aPath The file path of the database.
+
+ @return The `FMDatabaseQueue` object. `nil` on error.
+ */
+
+- (instancetype)initWithPath:(NSString*)aPath;
+
+/** Create queue using path and specified flags.
+
+ @param aPath The file path of the database.
+ @param openFlags Flags passed to the openWithFlags method of the database
+
+ @return The `FMDatabaseQueue` object. `nil` on error.
+ */
+
+- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags;
+
+/** Create queue using path and specified flags.
+
+ @param aPath The file path of the database.
+ @param openFlags Flags passed to the openWithFlags method of the database
+ @param vfsName The name of a custom virtual file system
+
+ @return The `FMDatabaseQueue` object. `nil` on error.
+ */
+
+- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags vfs:(NSString *)vfsName;
+
+/** Returns the Class of 'FMDatabase' subclass, that will be used to instantiate database object.
+
+ Subclasses can override this method to return specified Class of 'FMDatabase' subclass.
+
+ @return The Class of 'FMDatabase' subclass, that will be used to instantiate database object.
+ */
+
++ (Class)databaseClass;
+
+/** Close database used by queue. */
+
+- (void)close;
+
+///-----------------------------------------------
+/// @name Dispatching database operations to queue
+///-----------------------------------------------
+
+/** Synchronously perform database operations on queue.
+
+ @param block The code to be run on the queue of `FMDatabaseQueue`
+ */
+
+- (void)inDatabase:(void (^)(FMDatabase *db))block;
+
+/** Synchronously perform database operations on queue, using transactions.
+
+ @param block The code to be run on the queue of `FMDatabaseQueue`
+ */
+
+- (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
+
+/** Synchronously perform database operations on queue, using deferred transactions.
+
+ @param block The code to be run on the queue of `FMDatabaseQueue`
+ */
+
+- (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
+
+///-----------------------------------------------
+/// @name Dispatching database operations to queue
+///-----------------------------------------------
+
+/** Synchronously perform database operations using save point.
+
+ @param block The code to be run on the queue of `FMDatabaseQueue`
+ */
+
+// NOTE: you can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock.
+// If you need to nest, use FMDatabase's startSavePointWithName:error: instead.
+- (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block;
+
+@end
+
diff --git a/ios/Pods/FMDB/src/fmdb/FMDatabaseQueue.m b/ios/Pods/FMDB/src/fmdb/FMDatabaseQueue.m
new file mode 100644
index 0000000..c877a34
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMDatabaseQueue.m
@@ -0,0 +1,245 @@
+//
+// FMDatabaseQueue.m
+// fmdb
+//
+// Created by August Mueller on 6/22/11.
+// Copyright 2011 Flying Meat Inc. All rights reserved.
+//
+
+#import "FMDatabaseQueue.h"
+#import "FMDatabase.h"
+
+#if FMDB_SQLITE_STANDALONE
+#import
+#else
+#import
+#endif
+
+/*
+
+ Note: we call [self retain]; before using dispatch_sync, just incase
+ FMDatabaseQueue is released on another thread and we're in the middle of doing
+ something in dispatch_sync
+
+ */
+
+/*
+ * A key used to associate the FMDatabaseQueue object with the dispatch_queue_t it uses.
+ * This in turn is used for deadlock detection by seeing if inDatabase: is called on
+ * the queue's dispatch queue, which should not happen and causes a deadlock.
+ */
+static const void * const kDispatchQueueSpecificKey = &kDispatchQueueSpecificKey;
+
+@implementation FMDatabaseQueue
+
+@synthesize path = _path;
+@synthesize openFlags = _openFlags;
+
++ (instancetype)databaseQueueWithPath:(NSString*)aPath {
+
+ FMDatabaseQueue *q = [[self alloc] initWithPath:aPath];
+
+ FMDBAutorelease(q);
+
+ return q;
+}
+
++ (instancetype)databaseQueueWithPath:(NSString*)aPath flags:(int)openFlags {
+
+ FMDatabaseQueue *q = [[self alloc] initWithPath:aPath flags:openFlags];
+
+ FMDBAutorelease(q);
+
+ return q;
+}
+
++ (Class)databaseClass {
+ return [FMDatabase class];
+}
+
+- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags vfs:(NSString *)vfsName {
+
+ self = [super init];
+
+ if (self != nil) {
+
+ _db = [[[self class] databaseClass] databaseWithPath:aPath];
+ FMDBRetain(_db);
+
+#if SQLITE_VERSION_NUMBER >= 3005000
+ BOOL success = [_db openWithFlags:openFlags vfs:vfsName];
+#else
+ BOOL success = [_db open];
+#endif
+ if (!success) {
+ NSLog(@"Could not create database queue for path %@", aPath);
+ FMDBRelease(self);
+ return 0x00;
+ }
+
+ _path = FMDBReturnRetained(aPath);
+
+ _queue = dispatch_queue_create([[NSString stringWithFormat:@"fmdb.%@", self] UTF8String], NULL);
+ dispatch_queue_set_specific(_queue, kDispatchQueueSpecificKey, (__bridge void *)self, NULL);
+ _openFlags = openFlags;
+ }
+
+ return self;
+}
+
+- (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags {
+ return [self initWithPath:aPath flags:openFlags vfs:nil];
+}
+
+- (instancetype)initWithPath:(NSString*)aPath {
+
+ // default flags for sqlite3_open
+ return [self initWithPath:aPath flags:SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE vfs:nil];
+}
+
+- (instancetype)init {
+ return [self initWithPath:nil];
+}
+
+
+- (void)dealloc {
+
+ FMDBRelease(_db);
+ FMDBRelease(_path);
+
+ if (_queue) {
+ FMDBDispatchQueueRelease(_queue);
+ _queue = 0x00;
+ }
+#if ! __has_feature(objc_arc)
+ [super dealloc];
+#endif
+}
+
+- (void)close {
+ FMDBRetain(self);
+ dispatch_sync(_queue, ^() {
+ [self->_db close];
+ FMDBRelease(_db);
+ self->_db = 0x00;
+ });
+ FMDBRelease(self);
+}
+
+- (FMDatabase*)database {
+ if (!_db) {
+ _db = FMDBReturnRetained([FMDatabase databaseWithPath:_path]);
+
+#if SQLITE_VERSION_NUMBER >= 3005000
+ BOOL success = [_db openWithFlags:_openFlags];
+#else
+ BOOL success = [_db open];
+#endif
+ if (!success) {
+ NSLog(@"FMDatabaseQueue could not reopen database for path %@", _path);
+ FMDBRelease(_db);
+ _db = 0x00;
+ return 0x00;
+ }
+ }
+
+ return _db;
+}
+
+- (void)inDatabase:(void (^)(FMDatabase *db))block {
+ /* Get the currently executing queue (which should probably be nil, but in theory could be another DB queue
+ * and then check it against self to make sure we're not about to deadlock. */
+ FMDatabaseQueue *currentSyncQueue = (__bridge id)dispatch_get_specific(kDispatchQueueSpecificKey);
+ assert(currentSyncQueue != self && "inDatabase: was called reentrantly on the same queue, which would lead to a deadlock");
+
+ FMDBRetain(self);
+
+ dispatch_sync(_queue, ^() {
+
+ FMDatabase *db = [self database];
+ block(db);
+
+ if ([db hasOpenResultSets]) {
+ NSLog(@"Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]");
+
+#if defined(DEBUG) && DEBUG
+ NSSet *openSetCopy = FMDBReturnAutoreleased([[db valueForKey:@"_openResultSets"] copy]);
+ for (NSValue *rsInWrappedInATastyValueMeal in openSetCopy) {
+ FMResultSet *rs = (FMResultSet *)[rsInWrappedInATastyValueMeal pointerValue];
+ NSLog(@"query: '%@'", [rs query]);
+ }
+#endif
+ }
+ });
+
+ FMDBRelease(self);
+}
+
+
+- (void)beginTransaction:(BOOL)useDeferred withBlock:(void (^)(FMDatabase *db, BOOL *rollback))block {
+ FMDBRetain(self);
+ dispatch_sync(_queue, ^() {
+
+ BOOL shouldRollback = NO;
+
+ if (useDeferred) {
+ [[self database] beginDeferredTransaction];
+ }
+ else {
+ [[self database] beginTransaction];
+ }
+
+ block([self database], &shouldRollback);
+
+ if (shouldRollback) {
+ [[self database] rollback];
+ }
+ else {
+ [[self database] commit];
+ }
+ });
+
+ FMDBRelease(self);
+}
+
+- (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
+ [self beginTransaction:YES withBlock:block];
+}
+
+- (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
+ [self beginTransaction:NO withBlock:block];
+}
+
+- (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
+#if SQLITE_VERSION_NUMBER >= 3007000
+ static unsigned long savePointIdx = 0;
+ __block NSError *err = 0x00;
+ FMDBRetain(self);
+ dispatch_sync(_queue, ^() {
+
+ NSString *name = [NSString stringWithFormat:@"savePoint%ld", savePointIdx++];
+
+ BOOL shouldRollback = NO;
+
+ if ([[self database] startSavePointWithName:name error:&err]) {
+
+ block([self database], &shouldRollback);
+
+ if (shouldRollback) {
+ // We need to rollback and release this savepoint to remove it
+ [[self database] rollbackToSavePointWithName:name error:&err];
+ }
+ [[self database] releaseSavePointWithName:name error:&err];
+
+ }
+ });
+ FMDBRelease(self);
+ return err;
+#else
+ NSString *errorMessage = NSLocalizedString(@"Save point functions require SQLite 3.7", nil);
+ if (self.logsErrors) NSLog(@"%@", errorMessage);
+ return [NSError errorWithDomain:@"FMDatabase" code:0 userInfo:@{NSLocalizedDescriptionKey : errorMessage}];
+#endif
+}
+
+@end
diff --git a/ios/Pods/FMDB/src/fmdb/FMResultSet.h b/ios/Pods/FMDB/src/fmdb/FMResultSet.h
new file mode 100644
index 0000000..af0433b
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMResultSet.h
@@ -0,0 +1,468 @@
+#import
+
+#ifndef __has_feature // Optional.
+#define __has_feature(x) 0 // Compatibility with non-clang compilers.
+#endif
+
+#ifndef NS_RETURNS_NOT_RETAINED
+#if __has_feature(attribute_ns_returns_not_retained)
+#define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
+#else
+#define NS_RETURNS_NOT_RETAINED
+#endif
+#endif
+
+@class FMDatabase;
+@class FMStatement;
+
+/** Represents the results of executing a query on an ``.
+
+ ### See also
+
+ - ``
+ */
+
+@interface FMResultSet : NSObject {
+ FMDatabase *_parentDB;
+ FMStatement *_statement;
+
+ NSString *_query;
+ NSMutableDictionary *_columnNameToIndexMap;
+}
+
+///-----------------
+/// @name Properties
+///-----------------
+
+/** Executed query */
+
+@property (atomic, retain) NSString *query;
+
+/** `NSMutableDictionary` mapping column names to numeric index */
+
+@property (readonly) NSMutableDictionary *columnNameToIndexMap;
+
+/** `FMStatement` used by result set. */
+
+@property (atomic, retain) FMStatement *statement;
+
+///------------------------------------
+/// @name Creating and closing database
+///------------------------------------
+
+/** Create result set from ``
+
+ @param statement A `` to be performed
+
+ @param aDB A `` to be used
+
+ @return A `FMResultSet` on success; `nil` on failure
+ */
+
++ (instancetype)resultSetWithStatement:(FMStatement *)statement usingParentDatabase:(FMDatabase*)aDB;
+
+/** Close result set */
+
+- (void)close;
+
+- (void)setParentDB:(FMDatabase *)newDb;
+
+///---------------------------------------
+/// @name Iterating through the result set
+///---------------------------------------
+
+/** Retrieve next row for result set.
+
+ You must always invoke `next` or `nextWithError` before attempting to access the values returned in a query, even if you're only expecting one.
+
+ @return `YES` if row successfully retrieved; `NO` if end of result set reached
+
+ @see hasAnotherRow
+ */
+
+- (BOOL)next;
+
+/** Retrieve next row for result set.
+
+ You must always invoke `next` or `nextWithError` before attempting to access the values returned in a query, even if you're only expecting one.
+
+ @param outErr A 'NSError' object to receive any error object (if any).
+
+ @return 'YES' if row successfully retrieved; 'NO' if end of result set reached
+
+ @see hasAnotherRow
+ */
+
+- (BOOL)nextWithError:(NSError **)outErr;
+
+/** Did the last call to `` succeed in retrieving another row?
+
+ @return `YES` if the last call to `` succeeded in retrieving another record; `NO` if not.
+
+ @see next
+
+ @warning The `hasAnotherRow` method must follow a call to ``. If the previous database interaction was something other than a call to `next`, then this method may return `NO`, whether there is another row of data or not.
+ */
+
+- (BOOL)hasAnotherRow;
+
+///---------------------------------------------
+/// @name Retrieving information from result set
+///---------------------------------------------
+
+/** How many columns in result set
+
+ @return Integer value of the number of columns.
+ */
+
+- (int)columnCount;
+
+/** Column index for column name
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return Zero-based index for column.
+ */
+
+- (int)columnIndexForName:(NSString*)columnName;
+
+/** Column name for column index
+
+ @param columnIdx Zero-based index for column.
+
+ @return columnName `NSString` value of the name of the column.
+ */
+
+- (NSString*)columnNameForIndex:(int)columnIdx;
+
+/** Result set integer value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `int` value of the result set's column.
+ */
+
+- (int)intForColumn:(NSString*)columnName;
+
+/** Result set integer value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `int` value of the result set's column.
+ */
+
+- (int)intForColumnIndex:(int)columnIdx;
+
+/** Result set `long` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `long` value of the result set's column.
+ */
+
+- (long)longForColumn:(NSString*)columnName;
+
+/** Result set long value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `long` value of the result set's column.
+ */
+
+- (long)longForColumnIndex:(int)columnIdx;
+
+/** Result set `long long int` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `long long int` value of the result set's column.
+ */
+
+- (long long int)longLongIntForColumn:(NSString*)columnName;
+
+/** Result set `long long int` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `long long int` value of the result set's column.
+ */
+
+- (long long int)longLongIntForColumnIndex:(int)columnIdx;
+
+/** Result set `unsigned long long int` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `unsigned long long int` value of the result set's column.
+ */
+
+- (unsigned long long int)unsignedLongLongIntForColumn:(NSString*)columnName;
+
+/** Result set `unsigned long long int` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `unsigned long long int` value of the result set's column.
+ */
+
+- (unsigned long long int)unsignedLongLongIntForColumnIndex:(int)columnIdx;
+
+/** Result set `BOOL` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `BOOL` value of the result set's column.
+ */
+
+- (BOOL)boolForColumn:(NSString*)columnName;
+
+/** Result set `BOOL` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `BOOL` value of the result set's column.
+ */
+
+- (BOOL)boolForColumnIndex:(int)columnIdx;
+
+/** Result set `double` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `double` value of the result set's column.
+
+ */
+
+- (double)doubleForColumn:(NSString*)columnName;
+
+/** Result set `double` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `double` value of the result set's column.
+
+ */
+
+- (double)doubleForColumnIndex:(int)columnIdx;
+
+/** Result set `NSString` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `NSString` value of the result set's column.
+
+ */
+
+- (NSString*)stringForColumn:(NSString*)columnName;
+
+/** Result set `NSString` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `NSString` value of the result set's column.
+ */
+
+- (NSString*)stringForColumnIndex:(int)columnIdx;
+
+/** Result set `NSDate` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `NSDate` value of the result set's column.
+ */
+
+- (NSDate*)dateForColumn:(NSString*)columnName;
+
+/** Result set `NSDate` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `NSDate` value of the result set's column.
+
+ */
+
+- (NSDate*)dateForColumnIndex:(int)columnIdx;
+
+/** Result set `NSData` value for column.
+
+ This is useful when storing binary data in table (such as image or the like).
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `NSData` value of the result set's column.
+
+ */
+
+- (NSData*)dataForColumn:(NSString*)columnName;
+
+/** Result set `NSData` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `NSData` value of the result set's column.
+ */
+
+- (NSData*)dataForColumnIndex:(int)columnIdx;
+
+/** Result set `(const unsigned char *)` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `(const unsigned char *)` value of the result set's column.
+ */
+
+- (const unsigned char *)UTF8StringForColumnName:(NSString*)columnName;
+
+/** Result set `(const unsigned char *)` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `(const unsigned char *)` value of the result set's column.
+ */
+
+- (const unsigned char *)UTF8StringForColumnIndex:(int)columnIdx;
+
+/** Result set object for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
+
+ @see objectForKeyedSubscript:
+ */
+
+- (id)objectForColumnName:(NSString*)columnName;
+
+/** Result set object for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
+
+ @see objectAtIndexedSubscript:
+ */
+
+- (id)objectForColumnIndex:(int)columnIdx;
+
+/** Result set object for column.
+
+ This method allows the use of the "boxed" syntax supported in Modern Objective-C. For example, by defining this method, the following syntax is now supported:
+
+ id result = rs[@"employee_name"];
+
+ This simplified syntax is equivalent to calling:
+
+ id result = [rs objectForKeyedSubscript:@"employee_name"];
+
+ which is, it turns out, equivalent to calling:
+
+ id result = [rs objectForColumnName:@"employee_name"];
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
+ */
+
+- (id)objectForKeyedSubscript:(NSString *)columnName;
+
+/** Result set object for column.
+
+ This method allows the use of the "boxed" syntax supported in Modern Objective-C. For example, by defining this method, the following syntax is now supported:
+
+ id result = rs[0];
+
+ This simplified syntax is equivalent to calling:
+
+ id result = [rs objectForKeyedSubscript:0];
+
+ which is, it turns out, equivalent to calling:
+
+ id result = [rs objectForColumnName:0];
+
+ @param columnIdx Zero-based index for column.
+
+ @return Either `NSNumber`, `NSString`, `NSData`, or `NSNull`. If the column was `NULL`, this returns `[NSNull null]` object.
+ */
+
+- (id)objectAtIndexedSubscript:(int)columnIdx;
+
+/** Result set `NSData` value for column.
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `NSData` value of the result set's column.
+
+ @warning If you are going to use this data after you iterate over the next row, or after you close the
+result set, make sure to make a copy of the data first (or just use ``/``)
+If you don't, you're going to be in a world of hurt when you try and use the data.
+
+ */
+
+- (NSData*)dataNoCopyForColumn:(NSString*)columnName NS_RETURNS_NOT_RETAINED;
+
+/** Result set `NSData` value for column.
+
+ @param columnIdx Zero-based index for column.
+
+ @return `NSData` value of the result set's column.
+
+ @warning If you are going to use this data after you iterate over the next row, or after you close the
+ result set, make sure to make a copy of the data first (or just use ``/``)
+ If you don't, you're going to be in a world of hurt when you try and use the data.
+
+ */
+
+- (NSData*)dataNoCopyForColumnIndex:(int)columnIdx NS_RETURNS_NOT_RETAINED;
+
+/** Is the column `NULL`?
+
+ @param columnIdx Zero-based index for column.
+
+ @return `YES` if column is `NULL`; `NO` if not `NULL`.
+ */
+
+- (BOOL)columnIndexIsNull:(int)columnIdx;
+
+/** Is the column `NULL`?
+
+ @param columnName `NSString` value of the name of the column.
+
+ @return `YES` if column is `NULL`; `NO` if not `NULL`.
+ */
+
+- (BOOL)columnIsNull:(NSString*)columnName;
+
+
+/** Returns a dictionary of the row results mapped to case sensitive keys of the column names.
+
+ @returns `NSDictionary` of the row results.
+
+ @warning The keys to the dictionary are case sensitive of the column names.
+ */
+
+- (NSDictionary*)resultDictionary;
+
+/** Returns a dictionary of the row results
+
+ @see resultDictionary
+
+ @warning **Deprecated**: Please use `` instead. Also, beware that `` is case sensitive!
+ */
+
+- (NSDictionary*)resultDict __attribute__ ((deprecated));
+
+///-----------------------------
+/// @name Key value coding magic
+///-----------------------------
+
+/** Performs `setValue` to yield support for key value observing.
+
+ @param object The object for which the values will be set. This is the key-value-coding compliant object that you might, for example, observe.
+
+ */
+
+- (void)kvcMagic:(id)object;
+
+
+@end
+
diff --git a/ios/Pods/FMDB/src/fmdb/FMResultSet.m b/ios/Pods/FMDB/src/fmdb/FMResultSet.m
new file mode 100644
index 0000000..cfc51e1
--- /dev/null
+++ b/ios/Pods/FMDB/src/fmdb/FMResultSet.m
@@ -0,0 +1,422 @@
+#import "FMResultSet.h"
+#import "FMDatabase.h"
+#import "unistd.h"
+
+#if FMDB_SQLITE_STANDALONE
+#import
+#else
+#import
+#endif
+
+@interface FMDatabase ()
+- (void)resultSetDidClose:(FMResultSet *)resultSet;
+@end
+
+
+@implementation FMResultSet
+@synthesize query=_query;
+@synthesize statement=_statement;
+
++ (instancetype)resultSetWithStatement:(FMStatement *)statement usingParentDatabase:(FMDatabase*)aDB {
+
+ FMResultSet *rs = [[FMResultSet alloc] init];
+
+ [rs setStatement:statement];
+ [rs setParentDB:aDB];
+
+ NSParameterAssert(![statement inUse]);
+ [statement setInUse:YES]; // weak reference
+
+ return FMDBReturnAutoreleased(rs);
+}
+
+- (void)finalize {
+ [self close];
+ [super finalize];
+}
+
+- (void)dealloc {
+ [self close];
+
+ FMDBRelease(_query);
+ _query = nil;
+
+ FMDBRelease(_columnNameToIndexMap);
+ _columnNameToIndexMap = nil;
+
+#if ! __has_feature(objc_arc)
+ [super dealloc];
+#endif
+}
+
+- (void)close {
+ [_statement reset];
+ FMDBRelease(_statement);
+ _statement = nil;
+
+ // we don't need this anymore... (i think)
+ //[_parentDB setInUse:NO];
+ [_parentDB resultSetDidClose:self];
+ _parentDB = nil;
+}
+
+- (int)columnCount {
+ return sqlite3_column_count([_statement statement]);
+}
+
+- (NSMutableDictionary *)columnNameToIndexMap {
+ if (!_columnNameToIndexMap) {
+ int columnCount = sqlite3_column_count([_statement statement]);
+ _columnNameToIndexMap = [[NSMutableDictionary alloc] initWithCapacity:(NSUInteger)columnCount];
+ int columnIdx = 0;
+ for (columnIdx = 0; columnIdx < columnCount; columnIdx++) {
+ [_columnNameToIndexMap setObject:[NSNumber numberWithInt:columnIdx]
+ forKey:[[NSString stringWithUTF8String:sqlite3_column_name([_statement statement], columnIdx)] lowercaseString]];
+ }
+ }
+ return _columnNameToIndexMap;
+}
+
+- (void)kvcMagic:(id)object {
+
+ int columnCount = sqlite3_column_count([_statement statement]);
+
+ int columnIdx = 0;
+ for (columnIdx = 0; columnIdx < columnCount; columnIdx++) {
+
+ const char *c = (const char *)sqlite3_column_text([_statement statement], columnIdx);
+
+ // check for a null row
+ if (c) {
+ NSString *s = [NSString stringWithUTF8String:c];
+
+ [object setValue:s forKey:[NSString stringWithUTF8String:sqlite3_column_name([_statement statement], columnIdx)]];
+ }
+ }
+}
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
+
+- (NSDictionary*)resultDict {
+
+ NSUInteger num_cols = (NSUInteger)sqlite3_data_count([_statement statement]);
+
+ if (num_cols > 0) {
+ NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:num_cols];
+
+ NSEnumerator *columnNames = [[self columnNameToIndexMap] keyEnumerator];
+ NSString *columnName = nil;
+ while ((columnName = [columnNames nextObject])) {
+ id objectValue = [self objectForColumnName:columnName];
+ [dict setObject:objectValue forKey:columnName];
+ }
+
+ return FMDBReturnAutoreleased([dict copy]);
+ }
+ else {
+ NSLog(@"Warning: There seem to be no columns in this set.");
+ }
+
+ return nil;
+}
+
+#pragma clang diagnostic pop
+
+- (NSDictionary*)resultDictionary {
+
+ NSUInteger num_cols = (NSUInteger)sqlite3_data_count([_statement statement]);
+
+ if (num_cols > 0) {
+ NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:num_cols];
+
+ int columnCount = sqlite3_column_count([_statement statement]);
+
+ int columnIdx = 0;
+ for (columnIdx = 0; columnIdx < columnCount; columnIdx++) {
+
+ NSString *columnName = [NSString stringWithUTF8String:sqlite3_column_name([_statement statement], columnIdx)];
+ id objectValue = [self objectForColumnIndex:columnIdx];
+ [dict setObject:objectValue forKey:columnName];
+ }
+
+ return dict;
+ }
+ else {
+ NSLog(@"Warning: There seem to be no columns in this set.");
+ }
+
+ return nil;
+}
+
+
+
+
+- (BOOL)next {
+ return [self nextWithError:nil];
+}
+
+- (BOOL)nextWithError:(NSError **)outErr {
+
+ int rc = sqlite3_step([_statement statement]);
+
+ if (SQLITE_BUSY == rc || SQLITE_LOCKED == rc) {
+ NSLog(@"%s:%d Database busy (%@)", __FUNCTION__, __LINE__, [_parentDB databasePath]);
+ NSLog(@"Database busy");
+ if (outErr) {
+ *outErr = [_parentDB lastError];
+ }
+ }
+ else if (SQLITE_DONE == rc || SQLITE_ROW == rc) {
+ // all is well, let's return.
+ }
+ else if (SQLITE_ERROR == rc) {
+ NSLog(@"Error calling sqlite3_step (%d: %s) rs", rc, sqlite3_errmsg([_parentDB sqliteHandle]));
+ if (outErr) {
+ *outErr = [_parentDB lastError];
+ }
+ }
+ else if (SQLITE_MISUSE == rc) {
+ // uh oh.
+ NSLog(@"Error calling sqlite3_step (%d: %s) rs", rc, sqlite3_errmsg([_parentDB sqliteHandle]));
+ if (outErr) {
+ if (_parentDB) {
+ *outErr = [_parentDB lastError];
+ }
+ else {
+ // If 'next' or 'nextWithError' is called after the result set is closed,
+ // we need to return the appropriate error.
+ NSDictionary* errorMessage = [NSDictionary dictionaryWithObject:@"parentDB does not exist" forKey:NSLocalizedDescriptionKey];
+ *outErr = [NSError errorWithDomain:@"FMDatabase" code:SQLITE_MISUSE userInfo:errorMessage];
+ }
+
+ }
+ }
+ else {
+ // wtf?
+ NSLog(@"Unknown error calling sqlite3_step (%d: %s) rs", rc, sqlite3_errmsg([_parentDB sqliteHandle]));
+ if (outErr) {
+ *outErr = [_parentDB lastError];
+ }
+ }
+
+
+ if (rc != SQLITE_ROW) {
+ [self close];
+ }
+
+ return (rc == SQLITE_ROW);
+}
+
+- (BOOL)hasAnotherRow {
+ return sqlite3_errcode([_parentDB sqliteHandle]) == SQLITE_ROW;
+}
+
+- (int)columnIndexForName:(NSString*)columnName {
+ columnName = [columnName lowercaseString];
+
+ NSNumber *n = [[self columnNameToIndexMap] objectForKey:columnName];
+
+ if (n) {
+ return [n intValue];
+ }
+
+ NSLog(@"Warning: I could not find the column named '%@'.", columnName);
+
+ return -1;
+}
+
+
+
+- (int)intForColumn:(NSString*)columnName {
+ return [self intForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (int)intForColumnIndex:(int)columnIdx {
+ return sqlite3_column_int([_statement statement], columnIdx);
+}
+
+- (long)longForColumn:(NSString*)columnName {
+ return [self longForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (long)longForColumnIndex:(int)columnIdx {
+ return (long)sqlite3_column_int64([_statement statement], columnIdx);
+}
+
+- (long long int)longLongIntForColumn:(NSString*)columnName {
+ return [self longLongIntForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (long long int)longLongIntForColumnIndex:(int)columnIdx {
+ return sqlite3_column_int64([_statement statement], columnIdx);
+}
+
+- (unsigned long long int)unsignedLongLongIntForColumn:(NSString*)columnName {
+ return [self unsignedLongLongIntForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (unsigned long long int)unsignedLongLongIntForColumnIndex:(int)columnIdx {
+ return (unsigned long long int)[self longLongIntForColumnIndex:columnIdx];
+}
+
+- (BOOL)boolForColumn:(NSString*)columnName {
+ return [self boolForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (BOOL)boolForColumnIndex:(int)columnIdx {
+ return ([self intForColumnIndex:columnIdx] != 0);
+}
+
+- (double)doubleForColumn:(NSString*)columnName {
+ return [self doubleForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (double)doubleForColumnIndex:(int)columnIdx {
+ return sqlite3_column_double([_statement statement], columnIdx);
+}
+
+- (NSString*)stringForColumnIndex:(int)columnIdx {
+
+ if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
+ return nil;
+ }
+
+ const char *c = (const char *)sqlite3_column_text([_statement statement], columnIdx);
+
+ if (!c) {
+ // null row.
+ return nil;
+ }
+
+ return [NSString stringWithUTF8String:c];
+}
+
+- (NSString*)stringForColumn:(NSString*)columnName {
+ return [self stringForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (NSDate*)dateForColumn:(NSString*)columnName {
+ return [self dateForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (NSDate*)dateForColumnIndex:(int)columnIdx {
+
+ if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
+ return nil;
+ }
+
+ return [_parentDB hasDateFormatter] ? [_parentDB dateFromString:[self stringForColumnIndex:columnIdx]] : [NSDate dateWithTimeIntervalSince1970:[self doubleForColumnIndex:columnIdx]];
+}
+
+
+- (NSData*)dataForColumn:(NSString*)columnName {
+ return [self dataForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (NSData*)dataForColumnIndex:(int)columnIdx {
+
+ if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
+ return nil;
+ }
+
+ const char *dataBuffer = sqlite3_column_blob([_statement statement], columnIdx);
+ int dataSize = sqlite3_column_bytes([_statement statement], columnIdx);
+
+ if (dataBuffer == NULL) {
+ return nil;
+ }
+
+ return [NSData dataWithBytes:(const void *)dataBuffer length:(NSUInteger)dataSize];
+}
+
+
+- (NSData*)dataNoCopyForColumn:(NSString*)columnName {
+ return [self dataNoCopyForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (NSData*)dataNoCopyForColumnIndex:(int)columnIdx {
+
+ if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
+ return nil;
+ }
+
+ const char *dataBuffer = sqlite3_column_blob([_statement statement], columnIdx);
+ int dataSize = sqlite3_column_bytes([_statement statement], columnIdx);
+
+ NSData *data = [NSData dataWithBytesNoCopy:(void *)dataBuffer length:(NSUInteger)dataSize freeWhenDone:NO];
+
+ return data;
+}
+
+
+- (BOOL)columnIndexIsNull:(int)columnIdx {
+ return sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL;
+}
+
+- (BOOL)columnIsNull:(NSString*)columnName {
+ return [self columnIndexIsNull:[self columnIndexForName:columnName]];
+}
+
+- (const unsigned char *)UTF8StringForColumnIndex:(int)columnIdx {
+
+ if (sqlite3_column_type([_statement statement], columnIdx) == SQLITE_NULL || (columnIdx < 0)) {
+ return nil;
+ }
+
+ return sqlite3_column_text([_statement statement], columnIdx);
+}
+
+- (const unsigned char *)UTF8StringForColumnName:(NSString*)columnName {
+ return [self UTF8StringForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+- (id)objectForColumnIndex:(int)columnIdx {
+ int columnType = sqlite3_column_type([_statement statement], columnIdx);
+
+ id returnValue = nil;
+
+ if (columnType == SQLITE_INTEGER) {
+ returnValue = [NSNumber numberWithLongLong:[self longLongIntForColumnIndex:columnIdx]];
+ }
+ else if (columnType == SQLITE_FLOAT) {
+ returnValue = [NSNumber numberWithDouble:[self doubleForColumnIndex:columnIdx]];
+ }
+ else if (columnType == SQLITE_BLOB) {
+ returnValue = [self dataForColumnIndex:columnIdx];
+ }
+ else {
+ //default to a string for everything else
+ returnValue = [self stringForColumnIndex:columnIdx];
+ }
+
+ if (returnValue == nil) {
+ returnValue = [NSNull null];
+ }
+
+ return returnValue;
+}
+
+- (id)objectForColumnName:(NSString*)columnName {
+ return [self objectForColumnIndex:[self columnIndexForName:columnName]];
+}
+
+// returns autoreleased NSString containing the name of the column in the result set
+- (NSString*)columnNameForIndex:(int)columnIdx {
+ return [NSString stringWithUTF8String: sqlite3_column_name([_statement statement], columnIdx)];
+}
+
+- (void)setParentDB:(FMDatabase *)newDb {
+ _parentDB = newDb;
+}
+
+- (id)objectAtIndexedSubscript:(int)columnIdx {
+ return [self objectForColumnIndex:columnIdx];
+}
+
+- (id)objectForKeyedSubscript:(NSString *)columnName {
+ return [self objectForColumnName:columnName];
+}
+
+
+@end
diff --git a/ios/Pods/Headers/Private/FMDB/FMDB.h b/ios/Pods/Headers/Private/FMDB/FMDB.h
new file mode 120000
index 0000000..bcd6e0a
--- /dev/null
+++ b/ios/Pods/Headers/Private/FMDB/FMDB.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDB.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/FMDB/FMDatabase.h b/ios/Pods/Headers/Private/FMDB/FMDatabase.h
new file mode 120000
index 0000000..e69b333
--- /dev/null
+++ b/ios/Pods/Headers/Private/FMDB/FMDatabase.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDatabase.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/FMDB/FMDatabaseAdditions.h b/ios/Pods/Headers/Private/FMDB/FMDatabaseAdditions.h
new file mode 120000
index 0000000..b48a6a3
--- /dev/null
+++ b/ios/Pods/Headers/Private/FMDB/FMDatabaseAdditions.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDatabaseAdditions.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/FMDB/FMDatabasePool.h b/ios/Pods/Headers/Private/FMDB/FMDatabasePool.h
new file mode 120000
index 0000000..1d78001
--- /dev/null
+++ b/ios/Pods/Headers/Private/FMDB/FMDatabasePool.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDatabasePool.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/FMDB/FMDatabaseQueue.h b/ios/Pods/Headers/Private/FMDB/FMDatabaseQueue.h
new file mode 120000
index 0000000..9adde87
--- /dev/null
+++ b/ios/Pods/Headers/Private/FMDB/FMDatabaseQueue.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDatabaseQueue.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/FMDB/FMResultSet.h b/ios/Pods/Headers/Private/FMDB/FMResultSet.h
new file mode 120000
index 0000000..fd761d8
--- /dev/null
+++ b/ios/Pods/Headers/Private/FMDB/FMResultSet.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMResultSet.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/LKDBHelper/LKDB+Mapping.h b/ios/Pods/Headers/Private/LKDBHelper/LKDB+Mapping.h
new file mode 120000
index 0000000..03978d2
--- /dev/null
+++ b/ios/Pods/Headers/Private/LKDBHelper/LKDB+Mapping.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/LKDB+Mapping.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/LKDBHelper/LKDBHelper.h b/ios/Pods/Headers/Private/LKDBHelper/LKDBHelper.h
new file mode 120000
index 0000000..71d1a80
--- /dev/null
+++ b/ios/Pods/Headers/Private/LKDBHelper/LKDBHelper.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/LKDBHelper.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/LKDBHelper/LKDBUtils.h b/ios/Pods/Headers/Private/LKDBHelper/LKDBUtils.h
new file mode 120000
index 0000000..77e50e1
--- /dev/null
+++ b/ios/Pods/Headers/Private/LKDBHelper/LKDBUtils.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/LKDBUtils.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/LKDBHelper/NSObject+LKDBHelper.h b/ios/Pods/Headers/Private/LKDBHelper/NSObject+LKDBHelper.h
new file mode 120000
index 0000000..461a277
--- /dev/null
+++ b/ios/Pods/Headers/Private/LKDBHelper/NSObject+LKDBHelper.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/NSObject+LKDBHelper.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Private/LKDBHelper/NSObject+LKModel.h b/ios/Pods/Headers/Private/LKDBHelper/NSObject+LKModel.h
new file mode 120000
index 0000000..0f9a084
--- /dev/null
+++ b/ios/Pods/Headers/Private/LKDBHelper/NSObject+LKModel.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/NSObject+LKModel.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/FMDB/FMDB.h b/ios/Pods/Headers/Public/FMDB/FMDB.h
new file mode 120000
index 0000000..bcd6e0a
--- /dev/null
+++ b/ios/Pods/Headers/Public/FMDB/FMDB.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDB.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/FMDB/FMDatabase.h b/ios/Pods/Headers/Public/FMDB/FMDatabase.h
new file mode 120000
index 0000000..e69b333
--- /dev/null
+++ b/ios/Pods/Headers/Public/FMDB/FMDatabase.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDatabase.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/FMDB/FMDatabaseAdditions.h b/ios/Pods/Headers/Public/FMDB/FMDatabaseAdditions.h
new file mode 120000
index 0000000..b48a6a3
--- /dev/null
+++ b/ios/Pods/Headers/Public/FMDB/FMDatabaseAdditions.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDatabaseAdditions.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/FMDB/FMDatabasePool.h b/ios/Pods/Headers/Public/FMDB/FMDatabasePool.h
new file mode 120000
index 0000000..1d78001
--- /dev/null
+++ b/ios/Pods/Headers/Public/FMDB/FMDatabasePool.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDatabasePool.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/FMDB/FMDatabaseQueue.h b/ios/Pods/Headers/Public/FMDB/FMDatabaseQueue.h
new file mode 120000
index 0000000..9adde87
--- /dev/null
+++ b/ios/Pods/Headers/Public/FMDB/FMDatabaseQueue.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMDatabaseQueue.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/FMDB/FMResultSet.h b/ios/Pods/Headers/Public/FMDB/FMResultSet.h
new file mode 120000
index 0000000..fd761d8
--- /dev/null
+++ b/ios/Pods/Headers/Public/FMDB/FMResultSet.h
@@ -0,0 +1 @@
+../../../FMDB/src/fmdb/FMResultSet.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/LKDBHelper/LKDB+Mapping.h b/ios/Pods/Headers/Public/LKDBHelper/LKDB+Mapping.h
new file mode 120000
index 0000000..03978d2
--- /dev/null
+++ b/ios/Pods/Headers/Public/LKDBHelper/LKDB+Mapping.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/LKDB+Mapping.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/LKDBHelper/LKDBHelper.h b/ios/Pods/Headers/Public/LKDBHelper/LKDBHelper.h
new file mode 120000
index 0000000..71d1a80
--- /dev/null
+++ b/ios/Pods/Headers/Public/LKDBHelper/LKDBHelper.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/LKDBHelper.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/LKDBHelper/LKDBUtils.h b/ios/Pods/Headers/Public/LKDBHelper/LKDBUtils.h
new file mode 120000
index 0000000..77e50e1
--- /dev/null
+++ b/ios/Pods/Headers/Public/LKDBHelper/LKDBUtils.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/LKDBUtils.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/LKDBHelper/NSObject+LKDBHelper.h b/ios/Pods/Headers/Public/LKDBHelper/NSObject+LKDBHelper.h
new file mode 120000
index 0000000..461a277
--- /dev/null
+++ b/ios/Pods/Headers/Public/LKDBHelper/NSObject+LKDBHelper.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/NSObject+LKDBHelper.h
\ No newline at end of file
diff --git a/ios/Pods/Headers/Public/LKDBHelper/NSObject+LKModel.h b/ios/Pods/Headers/Public/LKDBHelper/NSObject+LKModel.h
new file mode 120000
index 0000000..0f9a084
--- /dev/null
+++ b/ios/Pods/Headers/Public/LKDBHelper/NSObject+LKModel.h
@@ -0,0 +1 @@
+../../../LKDBHelper/LKDBHelper/Helper/NSObject+LKModel.h
\ No newline at end of file
diff --git a/ios/Pods/LKDBHelper/LICENSE b/ios/Pods/LKDBHelper/LICENSE
new file mode 100644
index 0000000..feabb4c
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2012 Jianghuai Li (https://github.com/li6185377)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
\ No newline at end of file
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDB+Mapping.h b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDB+Mapping.h
new file mode 100644
index 0000000..ea272de
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDB+Mapping.h
@@ -0,0 +1,78 @@
+//
+// LKDBProperty+KeyMapping.h
+// LKDBHelper
+//
+// Created by LJH on 13-6-17.
+// Copyright (c) 2013年 ljh. All rights reserved.
+//
+
+#import "LKDBUtils.h"
+
+@interface NSObject (TableMapping)
+
+/**
+ * @brief Overwrite in your models if your property names don't match your Table Column names.
+ also use for set create table columns.
+
+ @{ sql column name : ( model property name ) or LKDBInherit or LKDBUserCalculate}
+
+ */
++ (NSDictionary*)getTableMapping;
+
+/***
+ simple set a column as "LKSQL_Mapping_UserCalculate"
+ column name
+*/
++ (void)setUserCalculateForCN:(NSString*)columnName;
+
+///property type name
++ (void)setUserCalculateForPTN:(NSString*)propertyTypeName;
+
+///binding columnName to PropertyName
++ (void)setTableColumnName:(NSString*)columnName bindingPropertyName:(NSString*)propertyName;
+
+///remove unwanted binding property
++ (void)removePropertyWithColumnName:(NSString*)columnName;
++ (void)removePropertyWithColumnNameArray:(NSArray*)columnNameArray;
+@end
+
+@interface LKDBProperty : NSObject
+
+///保存的方式
+@property (readonly, copy, nonatomic) NSString* type;
+
+///保存到数据的 列名
+@property (readonly, copy, nonatomic) NSString* sqlColumnName;
+///保存到数据的类型
+@property (readonly, copy, nonatomic) NSString* sqlColumnType;
+
+///属性名
+@property (readonly, copy, nonatomic) NSString* propertyName;
+///属性的类型
+@property (readonly, copy, nonatomic) NSString* propertyType;
+
+///属性的Protocol
+//@property(readonly,copy,nonatomic)NSString* propertyProtocol;
+
+///creating table's column
+@property BOOL isUnique;
+@property BOOL isNotNull;
+@property (copy, nonatomic) NSString* defaultValue;
+@property (copy, nonatomic) NSString* checkValue;
+@property NSInteger length;
+
+- (BOOL)isUserCalculate;
+@end
+
+@interface LKModelInfos : NSObject
+
+- (id)initWithKeyMapping:(NSDictionary*)keyMapping propertyNames:(NSArray*)propertyNames propertyType:(NSArray*)propertyType primaryKeys:(NSArray*)primaryKeys;
+
+@property (readonly, nonatomic) NSUInteger count;
+@property (readonly, nonatomic) NSArray* primaryKeys;
+
+- (LKDBProperty*)objectWithIndex:(NSInteger)index;
+- (LKDBProperty*)objectWithPropertyName:(NSString*)propertyName;
+- (LKDBProperty*)objectWithSqlColumnName:(NSString*)columnName;
+
+@end
\ No newline at end of file
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDB+Mapping.m b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDB+Mapping.m
new file mode 100644
index 0000000..9b08dad
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDB+Mapping.m
@@ -0,0 +1,283 @@
+//
+// LKDBProperty+KeyMapping.m
+// LKDBHelper
+//
+// Created by LJH on 13-6-17.
+// Copyright (c) 2013年 ljh. All rights reserved.
+//
+
+#import "LKDB+Mapping.h"
+#import "NSObject+LKModel.h"
+
+@interface LKModelInfos () {
+ __strong NSMutableDictionary* _proNameDic;
+ __strong NSMutableDictionary* _sqlNameDic;
+ __strong NSArray* _primaryKeys;
+}
+- (void)removeWithColumnName:(NSString*)columnName;
+- (void)addDBPropertyWithType:(NSString*)type cname:(NSString*)column_name ctype:(NSString*)ctype pname:(NSString*)pname ptype:(NSString*)ptype;
+
+- (void)updateProperty:(LKDBProperty*)property sqlColumnName:(NSString*)columnName;
+- (void)updateProperty:(LKDBProperty*)property propertyName:(NSString*)propertyName;
+@end
+
+#pragma mark - 声明属性
+@interface LKDBProperty ()
+@property (copy, nonatomic) NSString* type;
+
+@property (copy, nonatomic) NSString* sqlColumnName;
+@property (copy, nonatomic) NSString* sqlColumnType;
+
+@property (copy, nonatomic) NSString* propertyName;
+@property (copy, nonatomic) NSString* propertyType;
+
+- (id)initWithType:(NSString*)type cname:(NSString*)cname ctype:(NSString*)ctype pname:(NSString*)pname ptype:(NSString*)ptype;
+@end
+#pragma mark - LKDBProperty
+@implementation LKDBProperty
+
+- (id)initWithType:(NSString*)type cname:(NSString*)cname ctype:(NSString*)ctype pname:(NSString*)pname ptype:(NSString*)ptype
+{
+ self = [super init];
+ if (self) {
+ _type = [type copy];
+ _sqlColumnName = [cname copy];
+ _sqlColumnType = [ctype copy];
+ _propertyName = [pname copy];
+ _propertyType = [ptype copy];
+ }
+ return self;
+}
+- (void)enableUserCalculate
+{
+ _type = LKSQL_Mapping_UserCalculate;
+}
+- (BOOL)isUserCalculate
+{
+ return ([_type isEqualToString:LKSQL_Mapping_UserCalculate] || _propertyName == nil || [_propertyName isEqualToString:LKSQL_Mapping_UserCalculate]);
+}
+@end
+#pragma mark - NSObject - TableMapping
+@implementation NSObject (TableMapping)
++ (NSDictionary*)getTableMapping
+{
+ return nil;
+}
++ (void)setUserCalculateForCN:(NSString*)columnName
+{
+ if ([LKDBUtils checkStringIsEmpty:columnName]) {
+ LKErrorLog(@"columnName is null");
+ return;
+ }
+
+ LKModelInfos* infos = [self getModelInfos];
+ LKDBProperty* property = [infos objectWithSqlColumnName:columnName];
+ if (property) {
+ [property enableUserCalculate];
+ }
+ else {
+ [infos addDBPropertyWithType:LKSQL_Mapping_UserCalculate cname:columnName ctype:LKSQL_Type_Text pname:columnName ptype:@"NSString"];
+ }
+}
++ (void)setUserCalculateForPTN:(NSString*)propertyTypeName
+{
+ if ([LKDBUtils checkStringIsEmpty:propertyTypeName]) {
+ LKErrorLog(@"propertyTypeName is null");
+ return;
+ }
+
+ Class clazz = NSClassFromString(propertyTypeName);
+ LKModelInfos* infos = [self getModelInfos];
+ for (NSInteger i = 0; i < infos.count; i++) {
+ LKDBProperty* property = [infos objectWithIndex:i];
+
+ Class p_cls = NSClassFromString(property.propertyType);
+ BOOL isSubClass = ((p_cls && clazz) && [p_cls isSubclassOfClass:clazz]);
+ BOOL isNameEqual = [property.propertyType isEqualToString:propertyTypeName];
+ if (isSubClass || isNameEqual) {
+ [property enableUserCalculate];
+ }
+ }
+}
++ (void)setTableColumnName:(NSString*)columnName bindingPropertyName:(NSString*)propertyName
+{
+ if ([LKDBUtils checkStringIsEmpty:columnName] || [LKDBUtils checkStringIsEmpty:propertyName])
+ return;
+
+ LKModelInfos* infos = [self getModelInfos];
+
+ LKDBProperty* property = [infos objectWithPropertyName:propertyName];
+ if (property == nil) {
+ return;
+ }
+
+ LKDBProperty* column = [infos objectWithSqlColumnName:columnName];
+ if (column) {
+ [infos updateProperty:column propertyName:propertyName];
+ column.propertyType = property.propertyType;
+ }
+ else if ([property.sqlColumnName isEqualToString:property.propertyName]) {
+ [infos updateProperty:property sqlColumnName:columnName];
+ }
+ else {
+ [infos addDBPropertyWithType:LKSQL_Mapping_Binding cname:columnName ctype:LKSQL_Type_Text pname:propertyName ptype:property.propertyType];
+ }
+}
++ (void)removePropertyWithColumnNameArray:(NSArray*)columnNameArray
+{
+ LKModelInfos* infos = [self getModelInfos];
+ for (NSString* columnName in columnNameArray) {
+ [infos removeWithColumnName:columnName];
+ }
+}
++ (void)removePropertyWithColumnName:(NSString*)columnName
+{
+ [[self getModelInfos] removeWithColumnName:columnName];
+}
+@end
+
+#pragma mark - LKModelInfos
+
+@implementation LKModelInfos
+- (id)initWithKeyMapping:(NSDictionary*)keyMapping propertyNames:(NSArray*)propertyNames propertyType:(NSArray*)propertyType primaryKeys:(NSArray*)primaryKeys
+{
+ self = [super init];
+ if (self) {
+
+ _primaryKeys = [NSArray arrayWithArray:primaryKeys];
+
+ _proNameDic = [[NSMutableDictionary alloc] init];
+ _sqlNameDic = [[NSMutableDictionary alloc] init];
+
+ NSString *type, *column_name, *column_type, *property_name, *property_type;
+ if (keyMapping.count > 0) {
+ NSArray* sql_names = keyMapping.allKeys;
+
+ for (NSInteger i = 0; i < sql_names.count; i++) {
+
+ type = column_name = column_type = property_name = property_type = nil;
+
+ column_name = [sql_names objectAtIndex:i];
+ NSString* mappingValue = [keyMapping objectForKey:column_name];
+
+ //如果 设置的 属性名 是空白的 自动转成 使用ColumnName
+ if ([LKDBUtils checkStringIsEmpty:mappingValue]) {
+ NSLog(@"#ERROR sql column name %@ mapping value is empty,automatically converted LKDBInherit", column_name);
+ mappingValue = LKSQL_Mapping_Inherit;
+ }
+
+ if ([mappingValue isEqualToString:LKSQL_Mapping_UserCalculate]) {
+ type = LKSQL_Mapping_UserCalculate;
+ column_type = LKSQL_Type_Text;
+ }
+ else {
+
+ if ([mappingValue isEqualToString:LKSQL_Mapping_Inherit] || [mappingValue isEqualToString:LKSQL_Mapping_Binding]) {
+ type = LKSQL_Mapping_Inherit;
+ property_name = column_name;
+ }
+ else {
+ type = LKSQL_Mapping_Binding;
+ property_name = mappingValue;
+ }
+
+ NSUInteger index = [propertyNames indexOfObject:property_name];
+
+ NSAssert(index != NSNotFound, @"#ERROR TableMapping SQL column name %@ not fount %@ property name", column_name, property_name);
+
+ property_type = [propertyType objectAtIndex:index];
+ column_type = LKSQLTypeFromObjcType(property_type);
+ }
+
+ [self addDBPropertyWithType:type cname:column_name ctype:column_type pname:property_name ptype:property_type];
+ }
+ }
+ else {
+ for (NSInteger i = 0; i < propertyNames.count; i++) {
+
+ type = LKSQL_Mapping_Inherit;
+
+ property_name = [propertyNames objectAtIndex:i];
+ column_name = property_name;
+
+ property_type = [propertyType objectAtIndex:i];
+ column_type = LKSQLTypeFromObjcType(property_type);
+
+ [self addDBPropertyWithType:type cname:column_name ctype:column_type pname:property_name ptype:property_type];
+ }
+ }
+
+ if (_primaryKeys.count == 0) {
+ _primaryKeys = [NSArray arrayWithObject:@"rowid"];
+ }
+
+ for (NSString* pkname in _primaryKeys) {
+ if ([pkname.lowercaseString isEqualToString:@"rowid"]) {
+ if ([self objectWithSqlColumnName:pkname] == nil) {
+ [self addDBPropertyWithType:LKSQL_Mapping_Inherit cname:pkname ctype:LKSQL_Type_Int pname:pkname ptype:@"int"];
+ }
+ }
+ }
+ }
+ return self;
+}
+- (void)addDBPropertyWithType:(NSString*)type cname:(NSString*)column_name ctype:(NSString*)ctype pname:(NSString*)pname ptype:(NSString*)ptype
+{
+ LKDBProperty* db_property = [[LKDBProperty alloc] initWithType:type cname:column_name ctype:ctype pname:pname ptype:ptype];
+
+ if (db_property.propertyName) {
+ [_proNameDic setObject:db_property forKey:db_property.propertyName];
+ }
+ if (db_property.sqlColumnName) {
+ [_sqlNameDic setObject:db_property forKey:db_property.sqlColumnName];
+ }
+}
+- (NSArray*)primaryKeys
+{
+ return _primaryKeys;
+}
+- (NSUInteger)count
+{
+ return _sqlNameDic.count;
+}
+- (LKDBProperty*)objectWithIndex:(NSInteger)index
+{
+ if (index < _sqlNameDic.count) {
+ id key = [_sqlNameDic.allKeys objectAtIndex:index];
+ return [_sqlNameDic objectForKey:key];
+ }
+ return nil;
+}
+- (LKDBProperty*)objectWithPropertyName:(NSString*)propertyName
+{
+ return [_proNameDic objectForKey:propertyName];
+}
+- (LKDBProperty*)objectWithSqlColumnName:(NSString*)columnName
+{
+ return [_sqlNameDic objectForKey:columnName];
+}
+
+- (void)updateProperty:(LKDBProperty*)property propertyName:(NSString*)propertyName
+{
+ [_proNameDic removeObjectForKey:property.propertyName];
+ property.propertyName = propertyName;
+ [_proNameDic setObject:property forKey:propertyName];
+}
+- (void)updateProperty:(LKDBProperty*)property sqlColumnName:(NSString*)columnName
+{
+ [_sqlNameDic removeObjectForKey:property.sqlColumnName];
+ property.sqlColumnName = columnName;
+ [_sqlNameDic setObject:property forKey:columnName];
+}
+- (void)removeWithColumnName:(NSString*)columnName
+{
+ if ([LKDBUtils checkStringIsEmpty:columnName])
+ return;
+
+ LKDBProperty* property = [_sqlNameDic objectForKey:columnName];
+ if (property.propertyName) {
+ [_proNameDic removeObjectForKey:property.propertyName];
+ }
+ [_sqlNameDic removeObjectForKey:columnName];
+}
+@end
\ No newline at end of file
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBHelper.h b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBHelper.h
new file mode 100644
index 0000000..9ca3a3b
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBHelper.h
@@ -0,0 +1,261 @@
+//
+// LKDBHelper.h
+// LJH
+//
+// Created by LJH on 12-12-6.
+// Copyright (c) 2012年 LJH. All rights reserved.
+//
+
+#import "FMDatabase.h"
+#import "FMDatabaseQueue.h"
+#import
+
+#import "LKDBUtils.h"
+
+#import "LKDB+Mapping.h"
+
+#import "NSObject+LKDBHelper.h"
+#import "NSObject+LKModel.h"
+
+@interface LKDBHelper : NSObject
+
+/**
+ * @brief 是否打印数据库出错日志 默认 NO
+ */
++ (void)setLogError:(BOOL)logError;
+
+/**
+ * @brief filepath the use of : "documents/db/" + fileName + ".db"
+ * refer: FMDatabase.h + (instancetype)databaseWithPath:(NSString*)inPath;
+ */
+- (instancetype)initWithDBName:(NSString*)dbname;
+- (void)setDBName:(NSString*)fileName;
+
+/**
+ * @brief path of database file
+ * refer: FMDatabase.h + (instancetype)databaseWithPath:(NSString*)inPath;
+ */
+- (instancetype)initWithDBPath:(NSString*)filePath;
+- (void)setDBPath:(NSString*)filePath;
+
+/**
+ * @brief current encryption key.
+ */
+@property (copy, readonly, nonatomic) NSString* encryptionKey;
+
+/**
+ * @brief Set encryption key
+ refer: FMDatabase.h - (BOOL)setKey:(NSString*)key;
+ * invoking after the `LKDBHelper initialize` in YourModelClass.m `getUsingLKDBHelper` function
+ */
+- (BOOL)setKey:(NSString*)key;
+/// Reset encryption key
+- (BOOL)rekey:(NSString*)key;
+
+/**
+ * @brief execute database operations synchronously,not afraid of recursive deadlock
+
+ 同步执行数据库操作 可递归调用
+ */
+- (void)executeDB:(void (^)(FMDatabase* db))block;
+
+- (BOOL)executeSQL:(NSString*)sql arguments:(NSArray*)args;
+- (NSString*)executeScalarWithSQL:(NSString*)sql arguments:(NSArray*)args;
+
+/**
+ * @brief execute database operations synchronously in a transaction
+ block return the YES commit transaction returns the NO rollback transaction
+
+ 同步执行数据库操作 在事务内部
+ block 返回 YES commit 事务 返回 NO rollback 事务
+ */
+- (void)executeForTransaction:(BOOL (^)(LKDBHelper* helper))block;
+
+@end
+
+@interface LKDBHelper (DatabaseManager)
+
+///get table has created
+- (BOOL)getTableCreatedWithClass:(Class)model;
+- (BOOL)getTableCreatedWithTableName:(NSString*)tableName;
+
+///drop all table
+- (void)dropAllTable;
+
+///drop table with entity class
+- (BOOL)dropTableWithClass:(Class)modelClass;
+- (BOOL)dropTableWithTableName:(NSString*)tableName;
+
+@end
+
+@interface LKDBHelper (DatabaseExecute)
+/**
+ * @brief The number of rows query table
+ *
+ * @param modelClass entity class
+ * @param where can use NSString or NSDictionary or nil
+ *
+ * @return rows number
+ */
+- (NSInteger)rowCount:(Class)modelClass where:(id)where;
+- (void)rowCount:(Class)modelClass where:(id)where callback:(void (^)(NSInteger rowCount))callback;
+- (NSInteger)rowCountWithTableName:(NSString*)tableName where:(id)where;
+
+/**
+ * @brief query table
+ *
+ * @param params query condition
+ */
+- (NSMutableArray*)searchWithParams:(LKDBQueryParams*)params;
+
+/**
+ * @brief query table
+ *
+ * @param modelClass entity class
+ * @param where can use NSString or NSDictionary or nil
+
+ * @param orderBy The Sort: Ascending "name asc",Descending "name desc"
+ For example: @"rowid desc"x or @"rowid asc"
+
+ * @param offset Skip how many rows
+ * @param count Limit the number
+ *
+ * @return query finished result is an array(model instance collection)
+ */
+- (NSMutableArray*)search:(Class)modelClass where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count;
+
+/**
+ * query sql, query finished result is an array(model instance collection)
+ * you can use the "@t" replace Model TableName
+ * query sql use lowercase string
+ * 查询的sql语句 请使用小写 ,否则会不能自动获取 rowid
+ * example:
+ NSMutableArray* array = [[LKDBHelper getUsingLKDBHelper] searchWithSQL:@"select * from @t where blah blah.." toClass:[ModelClass class]];
+ *
+ */
+- (NSMutableArray*)searchWithSQL:(NSString*)sql toClass:(Class)modelClass;
+
+/**
+ * @brief don't do any operations of the sql
+ */
+- (NSMutableArray*)searchWithRAWSQL:(NSString*)sql toClass:(Class)modelClass;
+
+/**
+ * query sql, query finished result is an array(model instance collection)
+ * you can use the "@t" replace Model TableName and replace all ? placeholders with the va_list
+ * example:
+ NSMutableArray* array = [[LKDBHelper getUsingLKDBHelper] searc:[ModelClass class] withSQL:@"select rowid from name_table where name = ?", @"Swift"];
+ *
+ */
+- (NSMutableArray*)search:(Class)modelClass withSQL:(NSString*)sql, ...;
+
+/**
+ columns may NSArray or NSString if query column count == 1 return single column string array
+ other return models entity array
+ */
+- (NSMutableArray*)search:(Class)modelClass column:(id)columns where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count;
+
+/**
+ * @brief async search
+ */
+- (void)search:(Class)modelClass where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count callback:(void (^)(NSMutableArray* array))block;
+
+///return first model or nil
+- (id)searchSingle:(Class)modelClass where:(id)where orderBy:(NSString*)orderBy;
+
+/**
+ * @brief insert table
+ *
+ * @param model you want to insert the entity
+ *
+ * @return the inserted was successful
+ */
+- (BOOL)insertToDB:(NSObject*)model;
+- (void)insertToDB:(NSObject*)model callback:(void (^)(BOOL result))block;
+
+/**
+ * @brief insert when the entity primary key does not exist
+ *
+ * @param model you want to insert the entity
+ *
+ * @return the inserted was successful
+ */
+- (BOOL)insertWhenNotExists:(NSObject*)model;
+- (void)insertWhenNotExists:(NSObject*)model callback:(void (^)(BOOL result))block;
+
+/**
+ * @brief update table
+ *
+ * @param model you want to update the entity
+ * @param where can use NSString or NSDictionary or nil
+ when "where" is nil : update the value based on rowid column or primary key column
+ *
+ * @return the updated was successful
+ */
+- (BOOL)updateToDB:(NSObject*)model where:(id)where;
+- (void)updateToDB:(NSObject*)model where:(id)where callback:(void (^)(BOOL result))block;
+- (BOOL)updateToDB:(Class)modelClass set:(NSString*)sets where:(id)where;
+- (BOOL)updateToDBWithTableName:(NSString*)tableName set:(NSString*)sets where:(id)where;
+
+/**
+ * @brief delete table
+ *
+ * @param model you want to delete entity
+ when entity property "rowid" == 0 based on the primary key to delete
+ *
+ * @return the deleted was successful
+ */
+- (BOOL)deleteToDB:(NSObject*)model;
+- (void)deleteToDB:(NSObject*)model callback:(void (^)(BOOL result))block;
+
+/**
+ * @brief delete table with "where" constraint
+ *
+ * @param modelClass entity class
+ * @param where can use NSString or NSDictionary, can not is nil
+ *
+ * @return the deleted was successful
+ */
+- (BOOL)deleteWithClass:(Class)modelClass where:(id)where;
+- (void)deleteWithClass:(Class)modelClass where:(id)where callback:(void (^)(BOOL result))block;
+- (BOOL)deleteWithTableName:(NSString*)tableName where:(id)where;
+
+/**
+ * @brief entity exists?
+ * for primary key column
+ (if rowid > 0 would certainly exist so we do not rowid judgment)
+ * @param model entity
+ *
+ * @return YES: entity presence , NO: entity not exist
+ */
+- (BOOL)isExistsModel:(NSObject*)model;
+- (BOOL)isExistsClass:(Class)modelClass where:(id)where;
+- (BOOL)isExistsWithTableName:(NSString*)tableName where:(id)where;
+
+/**
+ * @brief Clear data based on the entity class
+ *
+ * @param modelClass entity class
+ */
++ (void)clearTableData:(Class)modelClass;
+
+/**
+ * @brief Clear Unused Data File
+ if you property has UIImage or NSData, will save their data in the (documents dir)
+ *
+ * @param modelClass entity class
+ * @param columns UIImage or NSData Column Name
+ */
++ (void)clearNoneImage:(Class)modelClass columns:(NSArray*)columns;
++ (void)clearNoneData:(Class)modelClass columns:(NSArray*)columns;
+
+@end
+
+@interface LKDBHelper (Deprecated_Nonfunctional)
+/// you can use [LKDBHelper getUsingLKDBHelper]
+#pragma mark - deprecated
++ (LKDBHelper*)sharedDBHelper __deprecated_msg("Method deprecated. Use `[Model getUsingLKDBHelper]`");
+- (BOOL)createTableWithModelClass:(Class)modelClass __deprecated_msg("Now you can not call it. Will automatically determine whether you need to create");
+- (void)setEncryptionKey:(NSString*)encryptionKey __deprecated_msg("Method deprecated. Use `setKey: OR resetKey:` invoking after the `LKDBHelper initialize` in YourModelClass.m `getUsingLKDBHelper` function");
+#pragma mark -
+@end
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBHelper.m b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBHelper.m
new file mode 100644
index 0000000..4add739
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBHelper.m
@@ -0,0 +1,1592 @@
+//
+// LKDBHelper.m
+// LJH
+//
+// Created by LJH on 12-12-6.
+// Copyright (c) 2012年 LJH. All rights reserved.
+//
+
+#import "LKDBHelper.h"
+#import
+
+#define LKDBCheck_tableNameIsInvalid(tableName) \
+ if ([LKDBUtils checkStringIsEmpty:tableName]) { \
+ LKErrorLog(@" \n Fail!Fail!Fail!Fail! \n with TableName is nil"); \
+ return NO; \
+ }
+
+#define LKDBCode_Async_Begin \
+ __LKDBWeak LKDBHelper* wself = self; \
+ [self asyncBlock :^{__strong LKDBHelper *sself = wself; \
+ if (sself) {
+
+#define LKDBCode_Async_End \
+ } \
+ }];
+
+#define LKDBCheck_modelIsInvalid(model) \
+ if (model == nil) { \
+ LKErrorLog(@"model is nil"); \
+ return NO; \
+ } \
+ if ([model.class getModelInfos].count == 0) { \
+ LKErrorLog(@"class: %@ property count is 0!!", NSStringFromClass(model.class)); \
+ return NO; \
+ } \
+ NSString* _model_tableName = model.db_tableName ?: [model.class getTableName]; \
+ if ([LKDBUtils checkStringIsEmpty:_model_tableName]) { \
+ LKErrorLog(@"model class name %@ table name is invalid!", NSStringFromClass(model.class)); \
+ return NO; \
+ }
+
+@interface NSObject (LKTabelStructure_Private)
+- (void)setDb_inserting:(BOOL)db_inserting;
+@end
+
+@interface LKDBWeakObject : NSObject
+@property (LKDBWeak, nonatomic) LKDBHelper* obj;
+@end
+
+@interface LKDBHelper ()
+
+@property (strong, nonatomic) NSMutableArray* createdTableNames;
+
+@property (LKDBWeak, nonatomic) FMDatabase* usingdb;
+@property (strong, nonatomic) FMDatabaseQueue* bindingQueue;
+@property (copy, nonatomic) NSString* dbPath;
+
+@property (strong, nonatomic) NSRecursiveLock* threadLock;
+@end
+
+@implementation LKDBHelper
+@synthesize encryptionKey = _encryptionKey;
+
+static BOOL LKDBLogErrorEnable = NO;
++(void)setLogError:(BOOL)logError
+{
+ if (LKDBLogErrorEnable == logError) {
+ return;
+ }
+#ifdef DEBUG
+ LKDBLogErrorEnable = logError;
+ NSMutableArray* dbArray = [self dbHelperSingleArray];
+ @synchronized(dbArray)
+ {
+ [dbArray enumerateObjectsUsingBlock:^(LKDBWeakObject* weakObj, NSUInteger idx, BOOL *stop) {
+ [weakObj.obj executeDB:^(FMDatabase *db) {
+ db.logsErrors = LKDBLogErrorEnable;
+ }];
+ }];
+ }
+#endif
+}
+
++ (NSMutableArray*)dbHelperSingleArray
+{
+ static __strong NSMutableArray* dbArray;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ dbArray = [NSMutableArray array];
+ });
+ return dbArray;
+}
+
++ (LKDBHelper*)dbHelperWithPath:(NSString*)dbFilePath save:(LKDBHelper*)helper
+{
+ NSMutableArray* dbArray = [self dbHelperSingleArray];
+ LKDBHelper* instance = nil;
+ @synchronized(dbArray)
+ {
+ if (helper) {
+ LKDBWeakObject* weakObj = [[LKDBWeakObject alloc] init];
+ weakObj.obj = helper;
+ [dbArray addObject:weakObj];
+ }
+ else if (dbFilePath) {
+ for (NSInteger i = 0; i < dbArray.count;) {
+ LKDBWeakObject* weakObj = [dbArray objectAtIndex:i];
+ if (weakObj.obj == nil) {
+ [dbArray removeObjectAtIndex:i];
+ continue;
+ }
+ else if ([weakObj.obj.dbPath isEqualToString:dbFilePath]) {
+ instance = weakObj.obj;
+ break;
+ }
+ i++;
+ }
+ }
+ }
+ return instance;
+}
+
+- (instancetype)init
+{
+ return [self initWithDBName:@"LKDB"];
+}
+
+- (instancetype)initWithDBName:(NSString*)dbname
+{
+ return [self initWithDBPath:[LKDBHelper getDBPathWithDBName:dbname]];
+}
+
+- (instancetype)initWithDBPath:(NSString*)filePath
+{
+ if ([LKDBUtils checkStringIsEmpty:filePath]) {
+ ///release self
+ self = nil;
+ return nil;
+ }
+
+ LKDBHelper* helper = [LKDBHelper dbHelperWithPath:filePath save:nil];
+
+ if (helper) {
+ self = helper;
+ }
+ else {
+ self = [super init];
+
+ if (self) {
+ self.threadLock = [[NSRecursiveLock alloc] init];
+ self.createdTableNames = [NSMutableArray array];
+
+ [self setDBPath:filePath];
+ [LKDBHelper dbHelperWithPath:nil save:self];
+ }
+ }
+
+ return self;
+}
+
+#pragma mark - init FMDB
++ (NSString*)getDBPathWithDBName:(NSString*)dbName
+{
+ NSString* fileName = nil;
+
+ if ([dbName hasSuffix:@".db"] == NO) {
+ fileName = [NSString stringWithFormat:@"%@.db", dbName];
+ }
+ else {
+ fileName = dbName;
+ }
+
+ NSString* filePath = [LKDBUtils getPathForDocuments:fileName inDir:@"db"];
+ return filePath;
+}
+
+- (void)setDBName:(NSString*)dbName
+{
+ [self setDBPath:[LKDBHelper getDBPathWithDBName:dbName]];
+}
+
+- (void)setDBPath:(NSString*)filePath
+{
+ if (self.bindingQueue && [self.dbPath isEqualToString:filePath]) {
+ return;
+ }
+ NSFileManager* fileManager = [NSFileManager defaultManager];
+ // 创建数据库目录
+ NSRange lastComponent = [filePath rangeOfString:@"/" options:NSBackwardsSearch];
+
+ if (lastComponent.length > 0) {
+ NSString* dirPath = [filePath substringToIndex:lastComponent.location];
+ BOOL isDir = NO;
+ BOOL isCreated = [fileManager fileExistsAtPath:dirPath isDirectory:&isDir];
+
+ if ((isCreated == NO) || (isDir == NO)) {
+ NSError* error = nil;
+#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
+ NSDictionary* attributes = @{ NSFileProtectionKey : NSFileProtectionNone };
+#else
+ NSDictionary* attributes = nil;
+#endif
+ BOOL success = [fileManager createDirectoryAtPath:dirPath
+ withIntermediateDirectories:YES
+ attributes:attributes
+ error:&error];
+
+ if (success == NO) {
+ LKErrorLog(@"create dir error: %@", error.debugDescription);
+ }
+ }
+ else {
+/**
+ * @brief Disk I/O error when device is locked
+ * https://github.com/ccgus/fmdb/issues/262
+ */
+#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
+ [fileManager setAttributes:@{ NSFileProtectionKey : NSFileProtectionNone }
+ ofItemAtPath:dirPath
+ error:nil];
+#endif
+ }
+ }
+
+ self.dbPath = filePath;
+ [self.bindingQueue close];
+
+#ifndef SQLITE_OPEN_FILEPROTECTION_NONE
+#define SQLITE_OPEN_FILEPROTECTION_NONE 0x00400000
+#endif
+
+ self.bindingQueue = [[FMDatabaseQueue alloc] initWithPath:filePath
+ flags:SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FILEPROTECTION_NONE];
+#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
+ if ([fileManager fileExistsAtPath:filePath]) {
+ [fileManager setAttributes:@{ NSFileProtectionKey : NSFileProtectionNone } ofItemAtPath:filePath error:nil];
+ }
+#endif
+
+ ///reset encryptionKey
+ _encryptionKey = nil;
+
+ [_bindingQueue inDatabase:^(FMDatabase* db) {
+ db.logsErrors = LKDBLogErrorEnable;
+ }];
+}
+
+#pragma mark - core
+- (void)executeDB:(void (^)(FMDatabase* db))block
+{
+ [_threadLock lock];
+
+ if (self.usingdb != nil) {
+ block(self.usingdb);
+ }
+ else {
+ if (_bindingQueue == nil) {
+ self.bindingQueue = [[FMDatabaseQueue alloc] initWithPath:_dbPath];
+ [_bindingQueue inDatabase:^(FMDatabase* db) {
+ db.logsErrors = LKDBLogErrorEnable;
+ if (_encryptionKey.length > 0) {
+ [db setKey:_encryptionKey];
+ }
+ }];
+ }
+ [_bindingQueue inDatabase:^(FMDatabase* db) {
+ self.usingdb = db;
+ block(db);
+ self.usingdb = nil;
+ }];
+ }
+
+ [_threadLock unlock];
+}
+
+- (BOOL)executeSQL:(NSString*)sql arguments:(NSArray*)args
+{
+ __block BOOL execute = NO;
+
+ [self executeDB:^(FMDatabase* db) {
+ if (args.count > 0) {
+ execute = [db executeUpdate:sql withArgumentsInArray:args];
+ }
+ else {
+ execute = [db executeUpdate:sql];
+ }
+
+ if (db.hadError) {
+ LKErrorLog(@" sql:%@ \n args:%@ \n sqlite error :%@ \n", sql, args, db.lastErrorMessage);
+ }
+ }];
+ return execute;
+}
+
+- (NSString*)executeScalarWithSQL:(NSString*)sql arguments:(NSArray*)args
+{
+ __block NSString* scalar = nil;
+
+ [self executeDB:^(FMDatabase* db) {
+ FMResultSet* set = nil;
+
+ if (args.count > 0) {
+ set = [db executeQuery:sql withArgumentsInArray:args];
+ }
+ else {
+ set = [db executeQuery:sql];
+ }
+
+ if (db.hadError) {
+ LKErrorLog(@" sql:%@ \n args:%@ \n sqlite error :%@ \n", sql, args, db.lastErrorMessage);
+ }
+
+ if (([set columnCount] > 0) && [set next]) {
+ scalar = [set stringForColumnIndex:0];
+ }
+
+ [set close];
+ }];
+ return scalar;
+}
+
+- (void)executeForTransaction:(BOOL (^)(LKDBHelper*))block
+{
+ LKDBHelper* helper = self;
+
+ [self executeDB:^(FMDatabase* db) {
+ BOOL inTransacttion = db.inTransaction;
+
+ if (!inTransacttion) {
+ [db beginTransaction];
+ }
+
+ BOOL isCommit = NO;
+
+ if (block) {
+ isCommit = block(helper);
+ }
+
+ if (!inTransacttion) {
+ if (isCommit) {
+ [db commit];
+ }
+ else {
+ [db rollback];
+ }
+ }
+ }];
+}
+
+// splice 'where' 拼接where语句
+- (NSMutableArray*)extractQuery:(NSMutableString*)query where:(id)where
+{
+ NSMutableArray* values = nil;
+
+ if ([where isKindOfClass:[NSString class]] && ([LKDBUtils checkStringIsEmpty:where] == NO)) {
+ [query appendFormat:@" where %@", where];
+ }
+ else if ([where isKindOfClass:[NSDictionary class]]) {
+ NSDictionary* dicWhere = where;
+
+ if (dicWhere.count > 0) {
+ values = [NSMutableArray arrayWithCapacity:dicWhere.count];
+ NSString* wherekey = [self dictionaryToSqlWhere:where andValues:values];
+ [query appendFormat:@" where %@", wherekey];
+ }
+ }
+
+ return values;
+}
+
+// dic where parse
+- (NSString*)dictionaryToSqlWhere:(NSDictionary*)dic andValues:(NSMutableArray*)values
+{
+ if (dic.count == 0) {
+ return @"";
+ }
+ NSMutableString* wherekey = [NSMutableString stringWithCapacity:0];
+ [dic enumerateKeysAndObjectsUsingBlock:^(NSString* key, id obj, BOOL *stop) {
+ if ([obj isKindOfClass:[NSArray class]]) {
+ NSArray* vlist = obj;
+ if (vlist.count == 0) {
+ return;
+ }
+ if (wherekey.length > 0) {
+ [wherekey appendString:@" and"];
+ }
+ [wherekey appendFormat:@" %@ in(", key];
+ [vlist enumerateObjectsUsingBlock:^(id vlist_obj, NSUInteger idx, BOOL *stop) {
+ if (idx > 0) {
+ [wherekey appendString:@","];
+ }
+ [wherekey appendString:@"?"];
+ [values addObject:vlist_obj];
+ }];
+ [wherekey appendString:@")"];
+ }
+ else {
+ if (wherekey.length > 0) {
+ [wherekey appendFormat:@" and %@=?", key];
+ }
+ else {
+ [wherekey appendFormat:@" %@=?", key];
+ }
+ [values addObject:obj];
+ }
+ }];
+ return [wherekey copy];
+}
+
+// where sql statements about model primary keys
+- (NSMutableString*)primaryKeyWhereSQLWithModel:(NSObject*)model addPValues:(NSMutableArray*)addPValues
+{
+ LKModelInfos* infos = [model.class getModelInfos];
+ NSArray* primaryKeys = infos.primaryKeys;
+ NSMutableString* pwhere = [NSMutableString string];
+
+ if (primaryKeys.count > 0) {
+ for (NSInteger i = 0; i < primaryKeys.count; i++) {
+ NSString* pk = [primaryKeys objectAtIndex:i];
+
+ if ([LKDBUtils checkStringIsEmpty:pk] == NO) {
+ LKDBProperty* property = [infos objectWithSqlColumnName:pk];
+ id pvalue = nil;
+
+ if (property && [property.type isEqualToString:LKSQL_Mapping_UserCalculate]) {
+ pvalue = [model userGetValueForModel:property];
+ }
+ else if (pk && property) {
+ pvalue = [model modelGetValue:property];
+ }
+
+ if (pvalue) {
+ if (pwhere.length > 0) {
+ [pwhere appendString:@"and"];
+ }
+
+ if (addPValues) {
+ [pwhere appendFormat:@" %@=? ", pk];
+ [addPValues addObject:pvalue];
+ }
+ else {
+ [pwhere appendFormat:@" %@='%@' ", pk, pvalue];
+ }
+ }
+ }
+ }
+ }
+
+ return pwhere;
+}
+
+#pragma mark - set key
+-(BOOL)setKey:(NSString *)key
+{
+ _encryptionKey = [key copy];
+ __block BOOL success = NO;
+ if (_bindingQueue && (_encryptionKey.length > 0)) {
+ [self executeDB:^(FMDatabase *db) {
+ success = [db setKey:_encryptionKey];
+ }];
+ }
+ return success;
+}
+-(BOOL)rekey:(NSString *)key
+{
+ _encryptionKey = [key copy];
+ __block BOOL success = NO;
+ if (_bindingQueue && (_encryptionKey.length > 0)) {
+ [self executeDB:^(FMDatabase *db) {
+ success = [db rekey:_encryptionKey];
+ }];
+ }
+ return success;
+}
+-(NSString *)encryptionKey
+{
+ return _encryptionKey;
+}
+#pragma mark - dealloc
+- (void)dealloc
+{
+ NSArray* array = [LKDBHelper dbHelperSingleArray];
+
+ @synchronized(array)
+ {
+ for (LKDBWeakObject* weakObject in array) {
+ if ([weakObject.obj isEqual:self]) {
+ weakObject.obj = nil;
+ }
+ }
+ }
+
+ [self.bindingQueue close];
+ self.usingdb = nil;
+ self.bindingQueue = nil;
+ self.dbPath = nil;
+ self.threadLock = nil;
+}
+
+@end
+@implementation LKDBHelper (DatabaseManager)
+
+- (void)dropAllTable
+{
+ [self executeDB:^(FMDatabase* db) {
+ FMResultSet* set = [db executeQuery:@"select name from sqlite_master where type='table'"];
+ NSMutableArray* dropTables = [NSMutableArray arrayWithCapacity:0];
+
+ while ([set next]) {
+ [dropTables addObject:[set stringForColumnIndex:0]];
+ }
+
+ [set close];
+
+ for (NSString* tableName in dropTables) {
+ if ([tableName hasPrefix:@"sqlite_"] == NO) {
+ NSString* dropTable = [NSString stringWithFormat:@"drop table %@", tableName];
+ [db executeUpdate:dropTable];
+ }
+ }
+
+ [self.createdTableNames removeAllObjects];
+ }];
+}
+
+- (BOOL)dropTableWithClass:(Class)modelClass
+{
+ return [self dropTableWithTableName:[modelClass getTableName]];
+}
+
+- (BOOL)dropTableWithTableName:(NSString*)tableName
+{
+ LKDBCheck_tableNameIsInvalid(tableName);
+
+ NSString* dropTable = [NSString stringWithFormat:@"drop table %@", tableName];
+
+ BOOL isDrop = [self executeSQL:dropTable arguments:nil];
+
+ [_threadLock lock];
+ [_createdTableNames removeObject:tableName];
+ [_threadLock unlock];
+
+ return isDrop;
+}
+
+- (void)fixSqlColumnsWithClass:(Class)clazz tableName:(NSString*)tableName
+{
+ [self executeDB:^(FMDatabase* db) {
+ LKModelInfos* infos = [clazz getModelInfos];
+
+ NSString* select = [NSString stringWithFormat:@"select * from %@ limit 0", tableName];
+ FMResultSet* set = [db executeQuery:select];
+ NSArray* columnArray = set.columnNameToIndexMap.allKeys;
+ [set close];
+
+ NSMutableArray* alterAddColumns = [NSMutableArray array];
+
+ for (NSInteger i = 0; i < infos.count; i++) {
+ LKDBProperty* property = [infos objectWithIndex:i];
+
+ if ([property.sqlColumnName.lowercaseString isEqualToString:@"rowid"]) {
+ continue;
+ }
+
+ ///数据库中不存在 需要alter add
+ if ([columnArray containsObject:property.sqlColumnName.lowercaseString] == NO) {
+ NSMutableString* addColumePars = [NSMutableString stringWithFormat:@"%@ %@", property.sqlColumnName, property.sqlColumnType];
+ [clazz columnAttributeWithProperty:property];
+
+ if ((property.length > 0) && [property.sqlColumnType isEqualToString:LKSQL_Type_Text]) {
+ [addColumePars appendFormat:@"(%ld)", (long)property.length];
+ }
+
+ if (property.isNotNull) {
+ [addColumePars appendFormat:@" %@", LKSQL_Attribute_NotNull];
+ }
+
+ if (property.checkValue) {
+ [addColumePars appendFormat:@" %@(%@)", LKSQL_Attribute_Check, property.checkValue];
+ }
+
+ if (property.defaultValue) {
+ [addColumePars appendFormat:@" %@ %@", LKSQL_Attribute_Default, property.defaultValue];
+ }
+
+ NSString* alertSQL = [NSString stringWithFormat:@"alter table %@ add column %@", tableName, addColumePars];
+ NSString* initColumnValue = [NSString stringWithFormat:@"update %@ set %@=%@", tableName, property.sqlColumnName, [property.sqlColumnType isEqualToString:LKSQL_Type_Text] ? @"''" : @"0"];
+
+ BOOL success = [db executeUpdate:alertSQL];
+
+ if (success) {
+ [db executeUpdate:initColumnValue];
+ [alterAddColumns addObject:property];
+ }
+ }
+ }
+
+ if (alterAddColumns.count > 0) {
+ [clazz dbDidAlterTable:self tableName:tableName addColumns:alterAddColumns];
+ }
+ }];
+}
+
+- (BOOL)_createTableWithModelClass:(Class)modelClass tableName:(NSString*)tableName
+{
+ if ([self getTableCreatedWithTableName:tableName]) {
+
+ // 已创建表 就跳过
+ [_threadLock lock];
+ if ([_createdTableNames containsObject:tableName] == NO) {
+ [_createdTableNames addObject:tableName];
+ }
+ [_threadLock unlock];
+
+ [self fixSqlColumnsWithClass:modelClass tableName:tableName];
+ return YES;
+ }
+
+ LKModelInfos* infos = [modelClass getModelInfos];
+
+ if (infos.count == 0) {
+ LKErrorLog(@"Class: %@ 0属性 不需要创建表", NSStringFromClass(modelClass));
+ return NO;
+ }
+
+ NSArray* primaryKeys = infos.primaryKeys;
+ NSString* rowidAliasName = [modelClass db_rowidAliasName];
+
+ NSMutableString* table_pars = [NSMutableString string];
+
+ for (NSInteger i = 0; i < infos.count; i++) {
+ if (i > 0) {
+ [table_pars appendString:@","];
+ }
+
+ LKDBProperty* property = [infos objectWithIndex:i];
+ [modelClass columnAttributeWithProperty:property];
+
+ NSString* columnType = property.sqlColumnType;
+
+ [table_pars appendFormat:@"%@ %@", property.sqlColumnName, columnType];
+
+ if ([property.sqlColumnType isEqualToString:LKSQL_Type_Text]) {
+ if (property.length > 0) {
+ [table_pars appendFormat:@"(%ld)", (long)property.length];
+ }
+ }
+
+ if (property.isNotNull) {
+ [table_pars appendFormat:@" %@", LKSQL_Attribute_NotNull];
+ }
+
+ if (property.isUnique) {
+ [table_pars appendFormat:@" %@", LKSQL_Attribute_Unique];
+ }
+
+ if (property.checkValue) {
+ [table_pars appendFormat:@" %@(%@)", LKSQL_Attribute_Check, property.checkValue];
+ }
+
+ if (property.defaultValue) {
+ [table_pars appendFormat:@" %@ %@", LKSQL_Attribute_Default, property.defaultValue];
+ }
+
+ if (rowidAliasName.length > 0) {
+ if ([property.sqlColumnName isEqualToString:rowidAliasName]) {
+ [table_pars appendString:@" primary key autoincrement"];
+ }
+ }
+ }
+
+ NSMutableString* pksb = [NSMutableString string];
+
+ ///联合主键
+ if (rowidAliasName.length == 0) {
+ if (primaryKeys.count > 0) {
+ pksb = [NSMutableString string];
+
+ for (NSInteger i = 0; i < primaryKeys.count; i++) {
+ NSString* pk = [primaryKeys objectAtIndex:i];
+
+ if (pksb.length > 0) {
+ [pksb appendString:@","];
+ }
+
+ [pksb appendString:pk];
+ }
+
+ if (pksb.length > 0) {
+ [pksb insertString:@",primary key(" atIndex:0];
+ [pksb appendString:@")"];
+ }
+ }
+ }
+
+ NSString* createTableSQL = [NSString stringWithFormat:@"CREATE TABLE IF NOT EXISTS %@(%@%@)", tableName, table_pars, pksb];
+
+ BOOL isCreated = [self executeSQL:createTableSQL arguments:nil];
+
+ [_threadLock lock];
+ if (isCreated) {
+ [_createdTableNames addObject:tableName];
+ [modelClass dbDidCreateTable:self tableName:tableName];
+ }
+ [_threadLock unlock];
+
+ return isCreated;
+}
+
+- (BOOL)getTableCreatedWithClass:(Class)modelClass
+{
+ return [self getTableCreatedWithTableName:[modelClass getTableName]];
+}
+
+- (BOOL)getTableCreatedWithTableName:(NSString*)tableName
+{
+ __block BOOL isTableCreated = NO;
+
+ [self executeDB:^(FMDatabase* db) {
+ FMResultSet* set = [db executeQuery:@"select count(name) from sqlite_master where type='table' and name=?", tableName];
+
+ if ([set next]) {
+ if ([set intForColumnIndex:0] > 0) {
+ isTableCreated = YES;
+ }
+ }
+
+ [set close];
+ }];
+ return isTableCreated;
+}
+
+@end
+
+@implementation LKDBHelper (DatabaseExecute)
+
+- (id)modelValueWithProperty:(LKDBProperty*)property model:(NSObject*)model
+{
+ id value = nil;
+
+ if (property.isUserCalculate) {
+ value = [model userGetValueForModel:property];
+ }
+ else {
+ value = [model modelGetValue:property];
+ }
+
+ if (value == nil) {
+ value = @"";
+ }
+
+ return value;
+}
+
+- (void)asyncBlock:(void (^)(void))block
+{
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
+}
+
+#pragma mark - row count operation
+- (NSInteger)rowCount:(Class)modelClass where:(id)where
+{
+ return [self rowCountWithTableName:[modelClass getTableName] where:where];
+}
+
+- (void)rowCount:(Class)modelClass where:(id)where callback:(void (^)(NSInteger))callback
+{
+ if (callback) {
+ LKDBCode_Async_Begin
+ NSInteger result = [sself rowCountWithTableName:[modelClass getTableName] where:where];
+ callback(result);
+ LKDBCode_Async_End
+ }
+}
+
+- (NSInteger)rowCountWithTableName:(NSString*)tableName where:(id)where
+{
+ LKDBCheck_tableNameIsInvalid(tableName);
+
+ NSMutableString* rowCountSql = [NSMutableString stringWithFormat:@"select count(rowid) from %@", tableName];
+
+ NSMutableArray* valuesarray = [self extractQuery:rowCountSql where:where];
+ NSInteger result = [[self executeScalarWithSQL:rowCountSql arguments:valuesarray] integerValue];
+
+ return result;
+}
+
+#pragma mark - search operation
+- (NSMutableArray*)search:(Class)modelClass where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count
+{
+ return [self searchBase:modelClass columns:nil where:where orderBy:orderBy offset:offset count:count];
+}
+
+- (NSMutableArray*)search:(Class)modelClass column:(id)columns where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count
+{
+ return [self searchBase:modelClass columns:columns where:where orderBy:orderBy offset:offset count:count];
+}
+
+- (id)searchSingle:(Class)modelClass where:(id)where orderBy:(NSString*)orderBy
+{
+ NSMutableArray* array = [self searchBase:modelClass columns:nil where:where orderBy:orderBy offset:0 count:1];
+
+ if (array.count > 0) {
+ return [array objectAtIndex:0];
+ }
+
+ return nil;
+}
+
+- (void)search:(Class)modelClass where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count callback:(void (^)(NSMutableArray*))block
+{
+ if (block) {
+ LKDBCode_Async_Begin
+ LKDBQueryParams* params = [[LKDBQueryParams alloc] init];
+ params.toClass = modelClass;
+
+ if ([where isKindOfClass:[NSDictionary class]]) {
+ params.whereDic = where;
+ }
+ else if ([where isKindOfClass:[NSString class]]) {
+ params.where = where;
+ }
+
+ params.orderBy = orderBy;
+ params.offset = offset;
+ params.count = count;
+
+ NSMutableArray* array = [sself searchBaseWithParams:params];
+ block(array);
+ LKDBCode_Async_End
+ }
+}
+
+- (NSMutableArray*)searchBaseWithParams:(LKDBQueryParams*)params
+{
+ if (params.toClass == nil) {
+ LKErrorLog(@"you search pars:%@! \n toClass is nil", params.getAllPropertysString);
+ return nil;
+ }
+
+ NSString* db_tableName = params.tableName;
+
+ if ([LKDBUtils checkStringIsEmpty:db_tableName]) {
+ db_tableName = [params.toClass getTableName];
+ }
+
+ if ([LKDBUtils checkStringIsEmpty:db_tableName]) {
+ LKErrorLog(@"you search pars:%@! \n tableName is empty", params.getAllPropertysString);
+ return nil;
+ }
+
+ NSString* columnsString = nil;
+ NSUInteger columnCount = 0;
+
+ if (params.columnArray.count > 0) {
+ columnCount = params.columnArray.count;
+ columnsString = [params.columnArray componentsJoinedByString:@","];
+ }
+ else if ([LKDBUtils checkStringIsEmpty:params.columns] == NO) {
+ columnsString = params.columns;
+ NSArray* array = [params.columns componentsSeparatedByString:@","];
+ columnCount = array.count;
+ }
+ else {
+ columnsString = @"*";
+ }
+
+ NSMutableString* query = [NSMutableString stringWithFormat:@"select %@,rowid from @t", columnsString];
+ NSMutableArray* whereValues = nil;
+
+ if (params.whereDic.count > 0) {
+ whereValues = [NSMutableArray arrayWithCapacity:params.whereDic.count];
+ NSString* wherekey = [self dictionaryToSqlWhere:params.whereDic andValues:whereValues];
+ [query appendFormat:@" where %@", wherekey];
+ }
+ else if ([LKDBUtils checkStringIsEmpty:params.where] == NO) {
+ [query appendFormat:@" where %@", params.where];
+ }
+
+ [self sqlString:query groupBy:params.groupBy orderBy:params.orderBy offset:params.offset count:params.count];
+
+ // replace @t to model table name
+ NSString* replaceTableName = [NSString stringWithFormat:@" %@ ", db_tableName];
+
+ if ([query hasSuffix:@" @t"]) {
+ [query appendString:@" "];
+ }
+
+ [query replaceOccurrencesOfString:@" @t " withString:replaceTableName options:NSCaseInsensitiveSearch range:NSMakeRange(0, query.length)];
+
+ __block NSMutableArray* results = nil;
+ [self executeDB:^(FMDatabase* db) {
+ FMResultSet* set = nil;
+
+ if (whereValues.count == 0) {
+ set = [db executeQuery:query];
+ }
+ else {
+ set = [db executeQuery:query withArgumentsInArray:whereValues];
+ }
+
+ if (columnCount == 1) {
+ results = [self executeOneColumnResult:set];
+ }
+ else {
+ results = [self executeResult:set Class:params.toClass tableName:db_tableName];
+ }
+
+ [set close];
+ }];
+ return results;
+}
+
+- (NSMutableArray*)searchWithParams:(LKDBQueryParams*)params
+{
+ if (params.callback) {
+ LKDBCode_Async_Begin
+ NSMutableArray* array = [sself searchBaseWithParams:params];
+ params.callback(array);
+ LKDBCode_Async_End return nil;
+ }
+ else {
+ return [self searchBaseWithParams:params];
+ }
+}
+
+- (NSMutableArray*)searchBase:(Class)modelClass columns:(id)columns where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count
+{
+ LKDBQueryParams* params = [[LKDBQueryParams alloc] init];
+
+ params.toClass = modelClass;
+
+ if ([columns isKindOfClass:[NSArray class]]) {
+ params.columnArray = columns;
+ }
+ else if ([columns isKindOfClass:[NSString class]]) {
+ params.columns = columns;
+ }
+
+ if ([where isKindOfClass:[NSDictionary class]]) {
+ params.whereDic = where;
+ }
+ else if ([where isKindOfClass:[NSString class]]) {
+ params.where = where;
+ }
+
+ params.orderBy = orderBy;
+ params.offset = offset;
+ params.count = count;
+
+ return [self searchBaseWithParams:params];
+}
+
+- (NSString *)replaceTableNameIfNeeded:(NSString *)sql withModelClass:(Class)modelClass
+{
+ // replace @t to model table name
+ NSString* replaceString = [[modelClass getTableName] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ if ([sql hasSuffix:@" @t"]) {
+ sql = [sql stringByAppendingString:@" "];
+ }
+ if ([sql componentsSeparatedByString:@" from "].count == 2 && [sql rangeOfString:@" join "].length == 0) {
+ sql = [sql stringByReplacingOccurrencesOfString:@" from " withString:[NSString stringWithFormat:@",%@.rowid from ", replaceString]];
+ }
+
+ sql = [sql stringByReplacingOccurrencesOfString:@" @t "
+ withString:
+ [NSString stringWithFormat:@" %@ ", replaceString]];
+ sql = [sql stringByReplacingOccurrencesOfString:@" @t,"
+ withString:
+ [NSString stringWithFormat:@" %@,", replaceString]];
+ sql = [sql stringByReplacingOccurrencesOfString:@",@t "
+ withString:
+ [NSString stringWithFormat:@",%@ ", replaceString]];
+
+ return sql;
+}
+
+- (NSMutableArray*)searchWithSQL:(NSString*)sql toClass:(Class)modelClass
+{
+ sql = [self replaceTableNameIfNeeded:sql withModelClass:modelClass];
+ return [self searchWithRAWSQL:sql toClass:modelClass];
+}
+
+- (NSMutableArray*)searchWithRAWSQL:(NSString*)sql toClass:(Class)modelClass
+{
+ __block NSMutableArray* results = nil;
+ [self executeDB:^(FMDatabase* db) {
+ FMResultSet* set = [db executeQuery:sql];
+ results = [self executeResult:set Class:modelClass tableName:nil];
+ [set close];
+ }];
+ return results;
+}
+
+- (NSMutableArray*)search:(Class)modelClass withSQL:(NSString*)sql, ...
+{
+ va_list args;
+ va_start(args, sql);
+
+ sql = [self replaceTableNameIfNeeded:sql withModelClass:modelClass];
+
+ va_list *argsPoint = &args;
+ __block NSMutableArray *results = nil;
+ [self executeDB:^(FMDatabase *db) {
+ FMResultSet *set = [db executeQuery:sql withVAList:*argsPoint];
+ results = [self executeResult:set Class:modelClass tableName:nil];
+ [set close];
+ }];
+
+ va_end(args);
+ return results;
+}
+
+- (void)sqlString:(NSMutableString*)sql groupBy:(NSString*)groupBy orderBy:(NSString*)orderby offset:(NSInteger)offset count:(NSInteger)count
+{
+ if ([LKDBUtils checkStringIsEmpty:groupBy] == NO) {
+ [sql appendFormat:@" group by %@", groupBy];
+ }
+
+ if ([LKDBUtils checkStringIsEmpty:orderby] == NO) {
+ [sql appendFormat:@" order by %@", orderby];
+ }
+
+ if (count > 0) {
+ [sql appendFormat:@" limit %ld offset %ld", (long)count, (long)offset];
+ }
+ else if (offset > 0) {
+ [sql appendFormat:@" limit %d offset %ld", INT_MAX, (long)offset];
+ }
+}
+
+- (NSMutableArray*)executeOneColumnResult:(FMResultSet*)set
+{
+ NSMutableArray* array = [NSMutableArray arrayWithCapacity:0];
+
+ while ([set next]) {
+ NSString* string = [set stringForColumnIndex:0];
+
+ if (string) {
+ [array addObject:string];
+ }
+ else {
+ NSData* data = [set dataForColumnIndex:0];
+
+ if (data) {
+ [array addObject:data];
+ }
+ }
+ }
+
+ return array;
+}
+
+- (NSMutableArray*)executeResult:(FMResultSet*)set Class:(Class)modelClass tableName:(NSString*)tableName
+{
+ NSMutableArray* array = [NSMutableArray arrayWithCapacity:0];
+ LKModelInfos* infos = [modelClass getModelInfos];
+ NSInteger columnCount = [set columnCount];
+
+ ///当主键是int类型时 会替换掉rowid
+ NSString* rowidAliasName = [modelClass db_rowidAliasName];
+
+ while ([set next]) {
+ NSObject* bindingModel = [[modelClass alloc] init];
+
+ for (int i = 0; i < columnCount; i++) {
+ NSString* sqlName = [set columnNameForIndex:i];
+ LKDBProperty* property = [infos objectWithSqlColumnName:sqlName];
+
+ BOOL isRowid = [[sqlName lowercaseString] isEqualToString:@"rowid"];
+
+ if ((isRowid == NO) && (property == nil)) {
+ continue;
+ }
+
+ if (isRowid && ((property == nil) || [property.sqlColumnType isEqualToString:LKSQL_Type_Int])) {
+ bindingModel.rowid = [set longForColumnIndex:i];
+ }
+ else {
+ BOOL isUserCalculate = [property.type isEqualToString:LKSQL_Mapping_UserCalculate];
+
+ if (property.propertyName && (isUserCalculate == NO)) {
+ NSString* sqlValue = [set stringForColumnIndex:i];
+ [bindingModel modelSetValue:property value:sqlValue];
+
+ if ([rowidAliasName isEqualToString:sqlName]) {
+ bindingModel.rowid = [set longForColumnIndex:i];
+ }
+ }
+ else {
+ NSData* sqlData = [set dataForColumnIndex:i];
+ NSString* sqlValue = [[NSString alloc] initWithData:sqlData encoding:NSUTF8StringEncoding];
+ [bindingModel userSetValueForModel:property value:sqlValue ?: sqlData];
+ }
+ }
+ }
+
+ bindingModel.db_tableName = tableName;
+ [modelClass dbDidSeleted:bindingModel];
+ [array addObject:bindingModel];
+ }
+
+ return array;
+}
+
+#pragma mark - insert operation
+- (BOOL)insertToDB:(NSObject*)model
+{
+ return [self insertBase:model];
+}
+
+- (void)insertToDB:(NSObject*)model callback:(void (^)(BOOL))block
+{
+ LKDBCode_Async_Begin
+ BOOL result = [sself insertBase:model];
+
+ if (block) {
+ block(result);
+ }
+
+ LKDBCode_Async_End
+}
+
+- (BOOL)insertWhenNotExists:(NSObject*)model
+{
+ if ([self isExistsModel:model] == NO) {
+ return [self insertToDB:model];
+ }
+
+ return NO;
+}
+
+- (void)insertWhenNotExists:(NSObject*)model callback:(void (^)(BOOL))block
+{
+ LKDBCode_Async_Begin
+ BOOL result = [sself insertWhenNotExists:model];
+
+ if (block) {
+ block(result);
+ }
+
+ LKDBCode_Async_End
+}
+
+- (BOOL)insertBase:(NSObject*)model
+{
+ LKDBCheck_modelIsInvalid(model);
+
+ Class modelClass = model.class;
+
+ // callback
+ if ([modelClass dbWillInsert:model] == NO) {
+ LKErrorLog(@"your cancel %@ insert", model);
+ return NO;
+ }
+
+ [model setDb_inserting:YES];
+
+ NSString* db_tableName = model.db_tableName ?: [modelClass getTableName];
+
+ // 检测是否创建过表
+ [_threadLock lock];
+ if ([_createdTableNames containsObject:db_tableName] == NO) {
+ [self _createTableWithModelClass:modelClass tableName:db_tableName];
+ }
+ [_threadLock unlock];
+
+ // --
+ LKModelInfos* infos = [modelClass getModelInfos];
+
+ NSMutableString* insertKey = [NSMutableString stringWithCapacity:0];
+ NSMutableString* insertValuesString = [NSMutableString stringWithCapacity:0];
+ NSMutableArray* insertValues = [NSMutableArray arrayWithCapacity:infos.count];
+
+ LKDBProperty* primaryProperty = [model singlePrimaryKeyProperty];
+
+ for (NSInteger i = 0; i < infos.count; i++) {
+ LKDBProperty* property = [infos objectWithIndex:i];
+
+ if ([LKDBUtils checkStringIsEmpty:property.sqlColumnName]) {
+ continue;
+ }
+
+ if ([property isEqual:primaryProperty]) {
+ if ([property.sqlColumnType isEqualToString:LKSQL_Type_Int] && [model singlePrimaryKeyValueIsEmpty]) {
+ continue;
+ }
+ }
+
+ id value = [self modelValueWithProperty:property model:model];
+
+ ///跳过 rowid = 0 的属性
+ if ([property.sqlColumnName isEqualToString:@"rowid"] && ([value intValue] == 0)) {
+ continue;
+ }
+
+ if (insertKey.length > 0) {
+ [insertKey appendString:@","];
+ [insertValuesString appendString:@","];
+ }
+
+ [insertKey appendString:property.sqlColumnName];
+ [insertValuesString appendString:@"?"];
+
+ [insertValues addObject:value];
+ }
+
+ // 拼接insertSQL 语句 采用 replace 插入
+ NSString* insertSQL = [NSString stringWithFormat:@"replace into %@(%@) values(%@)", db_tableName, insertKey, insertValuesString];
+
+ __block BOOL execute = NO;
+ __block sqlite_int64 lastInsertRowId = 0;
+
+ [self executeDB:^(FMDatabase* db) {
+ execute = [db executeUpdate:insertSQL withArgumentsInArray:insertValues];
+ lastInsertRowId = db.lastInsertRowId;
+
+ if (db.hadError) {
+ LKErrorLog(@" sql:%@ \n args:%@ \n sqlite error :%@ \n", insertSQL, insertValues, db.lastErrorMessage);
+ }
+ }];
+
+ model.rowid = (NSInteger)lastInsertRowId;
+
+ [model setDb_inserting:NO];
+
+ // callback
+ [modelClass dbDidInserted:model result:execute];
+ return execute;
+}
+
+#pragma mark - update operation
+- (BOOL)updateToDB:(NSObject*)model where:(id)where
+{
+ return [self updateToDBBase:model where:where];
+}
+
+- (void)updateToDB:(NSObject*)model where:(id)where callback:(void (^)(BOOL))block
+{
+ LKDBCode_Async_Begin
+ BOOL result = [sself updateToDBBase:model where:where];
+
+ if (block) {
+ block(result);
+ }
+
+ LKDBCode_Async_End
+}
+
+- (BOOL)updateToDBBase:(NSObject*)model where:(id)where
+{
+ LKDBCheck_modelIsInvalid(model);
+
+ Class modelClass = model.class;
+
+ // callback
+ if ([modelClass dbWillUpdate:model] == NO) {
+ LKErrorLog(@"you cancel %@ update.", model);
+ return NO;
+ }
+
+ NSString* db_tableName = model.db_tableName ?: [modelClass getTableName];
+
+ // 检测是否创建过表
+ [_threadLock lock];
+ if ([_createdTableNames containsObject:db_tableName] == NO) {
+ [self _createTableWithModelClass:modelClass tableName:db_tableName];
+ }
+ [_threadLock unlock];
+
+ LKModelInfos* infos = [modelClass getModelInfos];
+
+ NSMutableString* updateKey = [NSMutableString string];
+ NSMutableArray* updateValues = [NSMutableArray arrayWithCapacity:infos.count];
+
+ for (NSInteger i = 0; i < infos.count; i++) {
+ LKDBProperty* property = [infos objectWithIndex:i];
+ if ([LKDBUtils checkStringIsEmpty:property.sqlColumnName]) {
+ continue;
+ }
+ id value = [self modelValueWithProperty:property model:model];
+ ///跳过 rowid = 0 的属性
+ if ([property.sqlColumnName isEqualToString:@"rowid"]) {
+ int rowid = [value intValue];
+ if (rowid > 0) {
+ ///如果rowid 已经存在就不修改
+ NSString* rowidWhere = [NSString stringWithFormat:@"rowid=%d", rowid];
+ NSInteger rowCount = [self rowCountWithTableName:db_tableName where:rowidWhere];
+ if (rowCount > 0) {
+ continue;
+ }
+ }
+ else {
+ continue;
+ }
+ }
+ if (updateKey.length > 0) {
+ [updateKey appendString:@","];
+ }
+ [updateKey appendFormat:@"%@=?", property.sqlColumnName];
+ [updateValues addObject:value];
+ }
+
+ NSMutableString* updateSQL = [NSMutableString stringWithFormat:@"update %@ set %@ where ", db_tableName, updateKey];
+ // 添加where 语句
+ if ([where isKindOfClass:[NSString class]] && ([LKDBUtils checkStringIsEmpty:where] == NO)) {
+ [updateSQL appendString:where];
+ }
+ else if ([where isKindOfClass:[NSDictionary class]] && ([(NSDictionary*)where count] > 0)) {
+ NSMutableArray* valuearray = [NSMutableArray array];
+ NSString* sqlwhere = [self dictionaryToSqlWhere:where andValues:valuearray];
+
+ [updateSQL appendString:sqlwhere];
+ [updateValues addObjectsFromArray:valuearray];
+ }
+ else if (model.rowid > 0) {
+ [updateSQL appendFormat:@" rowid=%ld", (long)model.rowid];
+ }
+ else {
+ // 如果不通过 rowid 来 更新数据 那 primarykey 一定要有值
+ NSString* pwhere = [self primaryKeyWhereSQLWithModel:model addPValues:updateValues];
+
+ if (pwhere.length == 0) {
+ LKErrorLog(@"database update fail : %@ no find primary key!", NSStringFromClass(modelClass));
+ return NO;
+ }
+
+ [updateSQL appendString:pwhere];
+ }
+
+ BOOL execute = [self executeSQL:updateSQL arguments:updateValues];
+ // callback
+ [modelClass dbDidUpdated:model result:execute];
+
+ return execute;
+}
+
+- (BOOL)updateToDB:(Class)modelClass set:(NSString*)sets where:(id)where
+{
+ return [self updateToDBWithTableName:[modelClass getTableName] set:sets where:where];
+}
+
+- (BOOL)updateToDBWithTableName:(NSString*)tableName set:(NSString*)sets where:(id)where
+{
+ LKDBCheck_tableNameIsInvalid(tableName);
+
+ NSMutableString* updateSQL = [NSMutableString stringWithFormat:@"update %@ set %@ ", tableName, sets];
+ NSMutableArray* updateValues = [self extractQuery:updateSQL where:where];
+
+ BOOL execute = [self executeSQL:updateSQL arguments:updateValues];
+
+ return execute;
+}
+
+#pragma mark - delete operation
+- (BOOL)deleteToDB:(NSObject*)model
+{
+ return [self deleteToDBBase:model];
+}
+
+- (void)deleteToDB:(NSObject*)model callback:(void (^)(BOOL))block
+{
+ LKDBCode_Async_Begin
+ BOOL isDeleted = [sself deleteToDBBase:model];
+
+ if (block) {
+ block(isDeleted);
+ }
+
+ LKDBCode_Async_End
+}
+
+- (BOOL)deleteToDBBase:(NSObject*)model
+{
+ LKDBCheck_modelIsInvalid(model);
+
+ Class modelClass = model.class;
+
+ // callback
+ if ([modelClass dbWillDelete:model] == NO) {
+ LKErrorLog(@"you cancel %@ delete", model);
+ return NO;
+ }
+
+ NSString* db_tableName = model.db_tableName ?: [modelClass getTableName];
+
+ NSMutableString* deleteSQL = [NSMutableString stringWithFormat:@"delete from %@ where ", db_tableName];
+ NSMutableArray* parsArray = [NSMutableArray array];
+
+ if (model.rowid > 0) {
+ [deleteSQL appendFormat:@"rowid = %ld", (long)model.rowid];
+ }
+ else {
+ NSString* pwhere = [self primaryKeyWhereSQLWithModel:model addPValues:parsArray];
+
+ if (pwhere.length == 0) {
+ LKErrorLog(@"delete fail : %@ primary value is nil", NSStringFromClass(modelClass));
+ return NO;
+ }
+
+ [deleteSQL appendString:pwhere];
+ }
+
+ if (parsArray.count == 0) {
+ parsArray = nil;
+ }
+
+ BOOL execute = [self executeSQL:deleteSQL arguments:parsArray];
+
+ // callback
+ [modelClass dbDidDeleted:model result:execute];
+
+ return execute;
+}
+
+- (BOOL)deleteWithClass:(Class)modelClass where:(id)where
+{
+ return [self deleteWithTableName:[modelClass getTableName] where:where];
+}
+
+- (void)deleteWithClass:(Class)modelClass where:(id)where callback:(void (^)(BOOL))block
+{
+ LKDBCode_Async_Begin
+ BOOL isDeleted = [sself deleteWithTableName:[modelClass getTableName] where:where];
+
+ if (block) {
+ block(isDeleted);
+ }
+
+ LKDBCode_Async_End
+}
+
+- (BOOL)deleteWithTableName:(NSString*)tableName where:(id)where
+{
+ LKDBCheck_tableNameIsInvalid(tableName);
+
+ NSMutableString* deleteSQL = [NSMutableString stringWithFormat:@"delete from %@", tableName];
+ NSMutableArray* values = [self extractQuery:deleteSQL where:where];
+
+ BOOL result = [self executeSQL:deleteSQL arguments:values];
+ return result;
+}
+
+#pragma mark - other operation
+- (BOOL)isExistsModel:(NSObject*)model
+{
+ LKDBCheck_modelIsInvalid(model);
+ NSString* pwhere = nil;
+
+ if (model.rowid > 0) {
+ pwhere = [NSString stringWithFormat:@"rowid=%ld", (long)model.rowid];
+ }
+ else {
+ pwhere = [self primaryKeyWhereSQLWithModel:model addPValues:nil];
+ }
+
+ if (pwhere.length == 0) {
+ LKErrorLog(@"exists model fail: primary key is nil or invalid");
+ return NO;
+ }
+
+ return [self isExistsClass:model.class where:pwhere];
+}
+
+- (BOOL)isExistsClass:(Class)modelClass where:(id)where
+{
+ return [self isExistsWithTableName:[modelClass getTableName] where:where];
+}
+
+- (BOOL)isExistsWithTableName:(NSString*)tableName where:(id)where
+{
+ return [self rowCountWithTableName:tableName where:where] > 0;
+}
+
+#pragma mark - clear operation
+
++ (void)clearTableData:(Class)modelClass
+{
+ [[modelClass getUsingLKDBHelper] executeDB:^(FMDatabase* db) {
+ NSString* delete = [NSString stringWithFormat:@"DELETE FROM %@", [modelClass getTableName]];
+ [db executeUpdate:delete];
+ }];
+}
+
++ (void)clearNoneImage:(Class)modelClass columns:(NSArray*)columns
+{
+ [self clearFileWithTable:modelClass columns:columns type:1];
+}
+
++ (void)clearNoneData:(Class)modelClass columns:(NSArray*)columns
+{
+ [self clearFileWithTable:modelClass columns:columns type:2];
+}
+
+#define LKTestDirFilename @"LKTestDirFilename111"
++ (void)clearFileWithTable:(Class)modelClass columns:(NSArray*)columns type:(NSInteger)type
+{
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
+ NSString* testpath = nil;
+ switch (type) {
+ case 1:
+ testpath = [modelClass getDBImagePathWithName:LKTestDirFilename];
+ break;
+
+ case 2:
+ testpath = [modelClass getDBDataPathWithName:LKTestDirFilename];
+ break;
+ }
+
+ if ([LKDBUtils checkStringIsEmpty:testpath]) {
+ return;
+ }
+
+ NSString* dir = [testpath stringByReplacingOccurrencesOfString:LKTestDirFilename withString:@""];
+
+ NSUInteger count = columns.count;
+
+ // 获取该目录下所有文件名
+ NSArray* files = [LKDBUtils getFilenamesWithDir:dir];
+
+ NSString* seleteColumn = [columns componentsJoinedByString:@","];
+ NSMutableString* whereStr = [NSMutableString string];
+
+ for (NSInteger i = 0; i < count; i++) {
+ [whereStr appendFormat:@" %@ != '' ", [columns objectAtIndex:i]];
+
+ if (i < count - 1) {
+ [whereStr appendString:@" or "];
+ }
+ }
+
+ NSString* querySql = [NSString stringWithFormat:@"select %@ from %@ where %@", seleteColumn, [modelClass getTableName], whereStr];
+ __block NSArray* dbfiles;
+ [[modelClass getUsingLKDBHelper] executeDB:^(FMDatabase* db) {
+ NSMutableArray* tempfiles = [NSMutableArray arrayWithCapacity:6];
+ FMResultSet* set = [db executeQuery:querySql];
+
+ while ([set next]) {
+ for (int j = 0; j < count; j++) {
+ NSString* str = [set stringForColumnIndex:j];
+
+ if ([LKDBUtils checkStringIsEmpty:str] == NO) {
+ [tempfiles addObject:str];
+ }
+ }
+ }
+
+ [set close];
+ dbfiles = tempfiles;
+ }];
+
+ // 遍历 当不再数据库记录中 就删除
+ for (NSString* deletefile in files) {
+ if ([dbfiles indexOfObject:deletefile] == NSNotFound) {
+ [LKDBUtils deleteWithFilepath:[dir stringByAppendingPathComponent:deletefile]];
+ }
+ }
+ });
+}
+
+@end
+
+@implementation LKDBHelper (Deprecated_Nonfunctional)
+-(void)setEncryptionKey:(NSString *)encryptionKey
+{
+ _encryptionKey = [encryptionKey copy];
+ if (_bindingQueue && (_encryptionKey.length > 0)) {
+ [self executeDB:^(FMDatabase* db) {
+ [db setKey:_encryptionKey];
+ }];
+ }
+}
++ (LKDBHelper*)sharedDBHelper
+{
+ return [LKDBHelper getUsingLKDBHelper];
+}
+
+- (BOOL)createTableWithModelClass:(Class)modelClass
+{
+ return [self _createTableWithModelClass:modelClass tableName:[modelClass getTableName]];
+}
+
++ (LKDBHelper*)getUsingLKDBHelper
+{
+ return [[LKDBHelper alloc] init];
+}
+
+@end
+
+@implementation LKDBWeakObject
+
+@end
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBUtils.h b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBUtils.h
new file mode 100644
index 0000000..8dea904
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBUtils.h
@@ -0,0 +1,116 @@
+//
+// NSObject+LKUtils.h
+// LKDBHelper
+//
+// Created by LJH on 13-4-15.
+// Copyright (c) 2013年 ljh. All rights reserved.
+//
+
+#import
+
+@interface LKDBUtils : NSObject
+///返回根目录路径 "document"
++ (NSString*)getDocumentPath;
+///返回 "document/dir/" 文件夹路径
++ (NSString*)getDirectoryForDocuments:(NSString*)dir;
+///返回 "document/filename" 路径
++ (NSString*)getPathForDocuments:(NSString*)filename;
+///返回 "document/dir/filename" 路径
++ (NSString*)getPathForDocuments:(NSString*)filename inDir:(NSString*)dir;
+///文件是否存在
++ (BOOL)isFileExists:(NSString*)filepath;
+///删除文件
++ (BOOL)deleteWithFilepath:(NSString*)filepath;
+///返回该文件目录下 所有文件名
++ (NSArray*)getFilenamesWithDir:(NSString*)dir;
+
+///检测字符串是否为空
++ (BOOL)checkStringIsEmpty:(NSString*)string;
++ (NSString*)getTrimStringWithString:(NSString*)string;
+
+///把Date 转换成String
++ (NSString*)stringWithDate:(NSDate*)date;
+///把String 转换成Date
++ (NSDate*)dateWithString:(NSString*)str;
+///单例formatter
++ (NSNumberFormatter*)numberFormatter;
+
+@end
+
+#ifdef DEBUG
+#ifdef NSLog
+#define LKErrorLog(fmt, ...) NSLog(@"#LKDBHelper ERROR:\n" fmt, ##__VA_ARGS__);
+#else
+#define LKErrorLog(fmt, ...) NSLog(@"\n#LKDBHelper ERROR: %s [Line %d] \n" fmt, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
+#endif
+#else
+#define LKErrorLog(...)
+#endif
+
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_5_0 || __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7
+#define LKDBWeak weak
+#define __LKDBWeak __weak
+#else
+#define LKDBWeak unsafe_unretained
+#define __LKDBWeak
+#endif
+
+static NSString* const LKSQL_Type_Text = @"text";
+static NSString* const LKSQL_Type_Int = @"integer";
+static NSString* const LKSQL_Type_Double = @"double";
+static NSString* const LKSQL_Type_Blob = @"blob";
+
+static NSString* const LKSQL_Attribute_NotNull = @"NOT NULL";
+static NSString* const LKSQL_Attribute_PrimaryKey = @"PRIMARY KEY";
+static NSString* const LKSQL_Attribute_Default = @"DEFAULT";
+static NSString* const LKSQL_Attribute_Unique = @"UNIQUE";
+static NSString* const LKSQL_Attribute_Check = @"CHECK";
+static NSString* const LKSQL_Attribute_ForeignKey = @"FOREIGN KEY";
+
+static NSString* const LKSQL_Convert_FloatType = @"float_double_decimal";
+static NSString* const LKSQL_Convert_IntType = @"int_char_short_long";
+static NSString* const LKSQL_Convert_BlobType = @"";
+
+static NSString* const LKSQL_Mapping_Inherit = @"LKDBInherit";
+static NSString* const LKSQL_Mapping_Binding = @"LKDBBinding";
+static NSString* const LKSQL_Mapping_UserCalculate = @"LKDBUserCalculate";
+
+static NSString* const LKDB_TypeKey = @"DB_Type";
+
+static NSString* const LKDB_TypeKey_Model = @"DB_Type_Model";
+static NSString* const LKDB_TypeKey_JSON = @"DB_Type_JSON";
+static NSString* const LKDB_TypeKey_Combo = @"DB_Type_Combo";
+static NSString* const LKDB_TypeKey_Date = @"DB_Type_Date";
+
+static NSString* const LKDB_ValueKey = @"DB_Value";
+
+static NSString* const LKDB_TableNameKey = @"DB_TableName";
+static NSString* const LKDB_ClassKey = @"DB_Class";
+static NSString* const LKDB_RowIdKey = @"DB_RowId";
+static NSString* const LKDB_PValueKey = @"DB_PKeyValue";
+
+///Object-c type converted to SQLite type 把Object-c 类型 转换为sqlite 类型
+extern NSString* LKSQLTypeFromObjcType(NSString* objcType);
+
+@interface LKDBQueryParams : NSObject
+
+///columns or array
+@property (strong, nonatomic) NSString* columns;
+@property (strong, nonatomic) NSArray* columnArray;
+
+@property (strong, nonatomic) NSString* tableName;
+
+///where or dic
+@property (strong, nonatomic) NSString* where;
+@property (strong, nonatomic) NSDictionary* whereDic;
+
+@property (strong, nonatomic) NSString* groupBy;
+@property (strong, nonatomic) NSString* orderBy;
+
+@property (assign, nonatomic) NSInteger offset;
+@property (assign, nonatomic) NSInteger count;
+
+@property (assign, nonatomic) Class toClass;
+
+@property (copy, nonatomic) void (^callback)(NSMutableArray* results);
+@end
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBUtils.m b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBUtils.m
new file mode 100644
index 0000000..3d335c8
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/LKDBUtils.m
@@ -0,0 +1,185 @@
+//
+// NSObject+LKUtils.m
+// LKDBHelper
+//
+// Created by LJH on 13-4-15.
+// Copyright (c) 2013年 ljh. All rights reserved.
+//
+
+#import "LKDBUtils.h"
+
+@interface LKDateFormatter : NSDateFormatter
+@property (strong, nonatomic) NSRecursiveLock* lock;
+@end
+
+@implementation LKDateFormatter
+- (id)init
+{
+ self = [super init];
+ if (self) {
+ self.lock = [[NSRecursiveLock alloc] init];
+ self.generatesCalendarDates = YES;
+ self.dateStyle = NSDateFormatterNoStyle;
+ self.timeStyle = NSDateFormatterNoStyle;
+ self.AMSymbol = nil;
+ self.PMSymbol = nil;
+ NSLocale* locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
+ if (locale) {
+ [self setLocale:locale];
+ }
+ }
+ return self;
+}
+//防止在IOS5下 多线程 格式化时间时 崩溃
+- (NSDate*)dateFromString:(NSString*)string
+{
+ [_lock lock];
+ NSDate* date = [super dateFromString:string];
+ [_lock unlock];
+ return date;
+}
+- (NSString*)stringFromDate:(NSDate*)date
+{
+ [_lock lock];
+ NSString* string = [super stringFromDate:date];
+ [_lock unlock];
+ return string;
+}
+@end
+
+@interface LKNumberFormatter : NSNumberFormatter
+
+@end
+
+@implementation LKNumberFormatter
+-(NSString *)stringFromNumber:(NSNumber *)number
+{
+ NSString* string = [number stringValue];
+ return string;
+}
+-(NSNumber *)numberFromString:(NSString *)string
+{
+ NSNumber* number = [super numberFromString:string];
+ return number;
+}
+@end
+
+@implementation LKDBUtils
++ (NSString*)getDocumentPath
+{
+#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
+ NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString* documentsDirectory = [paths objectAtIndex:0];
+ return documentsDirectory;
+#else
+ NSString* homePath = [[NSBundle mainBundle] resourcePath];
+ return homePath;
+#endif
+}
++ (NSString*)getDirectoryForDocuments:(NSString*)dir
+{
+ NSString* dirPath = [[self getDocumentPath] stringByAppendingPathComponent:dir];
+ BOOL isDir = NO;
+ BOOL isCreated = [[NSFileManager defaultManager] fileExistsAtPath:dirPath isDirectory:&isDir];
+ if (isCreated == NO || isDir == NO) {
+ NSError* error = nil;
+ BOOL success = [[NSFileManager defaultManager] createDirectoryAtPath:dirPath withIntermediateDirectories:YES attributes:nil error:&error];
+ if (success == NO)
+ NSLog(@"create dir error: %@", error.debugDescription);
+ }
+ return dirPath;
+}
++ (NSString*)getPathForDocuments:(NSString*)filename
+{
+ return [[self getDocumentPath] stringByAppendingPathComponent:filename];
+}
++ (NSString*)getPathForDocuments:(NSString*)filename inDir:(NSString*)dir
+{
+ return [[self getDirectoryForDocuments:dir] stringByAppendingPathComponent:filename];
+}
++ (BOOL)isFileExists:(NSString*)filepath
+{
+ return [[NSFileManager defaultManager] fileExistsAtPath:filepath];
+}
++ (BOOL)deleteWithFilepath:(NSString*)filepath
+{
+ return [[NSFileManager defaultManager] removeItemAtPath:filepath error:nil];
+}
++ (NSArray*)getFilenamesWithDir:(NSString*)dir
+{
+ NSFileManager* fileManager = [NSFileManager defaultManager];
+ NSArray* fileList = [fileManager contentsOfDirectoryAtPath:dir error:nil];
+ return fileList;
+}
++ (BOOL)checkStringIsEmpty:(NSString*)string
+{
+ if (string == nil) {
+ return YES;
+ }
+ if ([string isKindOfClass:[NSString class]] == NO) {
+ return YES;
+ }
+ if (string.length == 0) {
+ return YES;
+ }
+ return [[self getTrimStringWithString:string] isEqualToString:@""];
+}
++ (NSString*)getTrimStringWithString:(NSString*)string
+{
+ return [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+}
+
++ (NSDateFormatter*)getDBDateFormat
+{
+ static NSDateFormatter* format;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ format = [[LKDateFormatter alloc] init];
+ format.dateFormat = @"yyyy-MM-dd HH:mm:ss";
+ });
+ return format;
+}
++ (NSString*)stringWithDate:(NSDate*)date
+{
+ NSDateFormatter* formatter = [self getDBDateFormat];
+ NSString* datestr = [formatter stringFromDate:date];
+ if (datestr.length > 19) {
+ datestr = [datestr substringToIndex:19];
+ }
+ return datestr;
+}
++ (NSDate*)dateWithString:(NSString*)str
+{
+ NSDateFormatter* formatter = [self getDBDateFormat];
+ NSDate* date = [formatter dateFromString:str];
+ return date;
+}
++(NSNumberFormatter *)numberFormatter
+{
+ static NSNumberFormatter* numberFormatter = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ numberFormatter = [[LKNumberFormatter alloc] init];
+ });
+ return numberFormatter;
+}
+@end
+
+inline NSString* LKSQLTypeFromObjcType(NSString* objcType)
+{
+ if ([LKSQL_Convert_IntType rangeOfString:objcType].length > 0) {
+ return LKSQL_Type_Int;
+ }
+ if ([LKSQL_Convert_FloatType rangeOfString:objcType].length > 0) {
+ return LKSQL_Type_Double;
+ }
+ if ([LKSQL_Convert_BlobType rangeOfString:objcType].length > 0) {
+ return LKSQL_Type_Blob;
+ }
+
+ return LKSQL_Type_Text;
+}
+
+@implementation LKDBQueryParams
+
+@end
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKDBHelper.h b/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKDBHelper.h
new file mode 100644
index 0000000..4412031
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKDBHelper.h
@@ -0,0 +1,86 @@
+//
+// NSObject+LKDBHelper.h
+// LKDBHelper
+//
+// Created by LJH on 13-6-8.
+// Copyright (c) 2013年 ljh. All rights reserved.
+//
+
+#import
+#import "LKDBHelper.h"
+
+@class LKDBHelper;
+
+@interface NSObject (LKDBHelper_Delegate)
+
++ (void)dbDidCreateTable:(LKDBHelper*)helper tableName:(NSString*)tableName;
++ (void)dbDidAlterTable:(LKDBHelper*)helper tableName:(NSString*)tableName addColumns:(NSArray*)columns;
+
++ (BOOL)dbWillInsert:(NSObject*)entity;
++ (void)dbDidInserted:(NSObject*)entity result:(BOOL)result;
+
++ (BOOL)dbWillUpdate:(NSObject*)entity;
++ (void)dbDidUpdated:(NSObject*)entity result:(BOOL)result;
+
++ (BOOL)dbWillDelete:(NSObject*)entity;
++ (void)dbDidDeleted:(NSObject*)entity result:(BOOL)result;
+
+///data read finish
++ (void)dbDidSeleted:(NSObject*)entity;
+
+@end
+
+//only simplify synchronous function
+@interface NSObject (LKDBHelper_Execute)
+
+/**
+ * 返回行数
+ *
+ * @param where type can NSDictionary or NSString
+ *
+ * @return row count
+ */
++ (NSInteger)rowCountWithWhere:(id)where, ...;
++ (NSInteger)rowCountWithWhereFormat:(id)where, ...;
+
+/**
+ * 搜索
+ *
+ * @param columns type can NSArray or NSString(Search for a specific column. Search only one, only to return the contents of the column collection)
+
+ * @param where where type can NSDictionary or NSString
+ * @param orderBy
+ * @param offset
+ * @param count
+ *
+ * @return model collection or contents of the columns collection
+ */
++ (NSMutableArray*)searchColumn:(id)columns where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count;
++ (NSMutableArray*)searchWithWhere:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count;
++ (NSMutableArray*)searchWithWhere:(id)where;
++ (NSMutableArray*)searchWithSQL:(NSString*)sql;
+
++ (id)searchSingleWithWhere:(id)where orderBy:(NSString*)orderBy;
+
++ (BOOL)insertToDB:(NSObject*)model;
++ (BOOL)insertWhenNotExists:(NSObject*)model;
++ (BOOL)updateToDB:(NSObject*)model where:(id)where, ...;
++ (BOOL)updateToDBWithSet:(NSString*)sets where:(id)where, ...;
++ (BOOL)deleteToDB:(NSObject*)model;
++ (BOOL)deleteWithWhere:(id)where, ...;
++ (BOOL)isExistsWithModel:(NSObject*)model;
+
+- (BOOL)updateToDB;
+- (BOOL)saveToDB;
+- (BOOL)deleteToDB;
+- (BOOL)isExistsFromDB;
+
+///异步插入数据 async insert array , completed 也是在子线程直接回调的
++ (void)insertArrayByAsyncToDB:(NSArray*)models;
++ (void)insertArrayByAsyncToDB:(NSArray*)models completed:(void (^)(BOOL allInserted))completedBlock;
+
+///begin translate for insert models 开始事务插入数组
++ (void)insertToDBWithArray:(NSArray*)models filter:(void (^)(id model, BOOL inserted, BOOL* rollback))filter;
++ (void)insertToDBWithArray:(NSArray*)models filter:(void (^)(id model, BOOL inserted, BOOL* rollback))filter completed:(void (^)(BOOL allInserted))completedBlock;
+
+@end
\ No newline at end of file
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKDBHelper.m b/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKDBHelper.m
new file mode 100644
index 0000000..42eeb75
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKDBHelper.m
@@ -0,0 +1,215 @@
+//
+// NSObject+LKDBHelper.m
+// LKDBHelper
+//
+// Created by LJH on 13-6-8.
+// Copyright (c) 2013年 ljh. All rights reserved.
+//
+
+#import "NSObject+LKDBHelper.h"
+
+@implementation NSObject (LKDBHelper_Delegate)
+
++ (void)dbDidCreateTable:(LKDBHelper*)helper tableName:(NSString*)tableName {}
++ (void)dbDidAlterTable:(LKDBHelper*)helper tableName:(NSString*)tableName addColumns:(NSArray*)columns {}
+
++ (void)dbDidInserted:(NSObject*)entity result:(BOOL)result {}
++ (void)dbDidDeleted:(NSObject*)entity result:(BOOL)result {}
++ (void)dbDidUpdated:(NSObject*)entity result:(BOOL)result {}
++ (void)dbDidSeleted:(NSObject*)entity {}
+
++ (BOOL)dbWillDelete:(NSObject*)entity
+{
+ return YES;
+}
++ (BOOL)dbWillInsert:(NSObject*)entity
+{
+ return YES;
+}
++ (BOOL)dbWillUpdate:(NSObject*)entity
+{
+ return YES;
+}
+@end
+
+@implementation NSObject (LKDBHelper)
+
+#pragma mark - simplify synchronous function
++ (BOOL)checkModelClass:(NSObject*)model
+{
+ if ([model isMemberOfClass:self])
+ return YES;
+
+ NSLog(@"%@ can not use %@", NSStringFromClass(self), NSStringFromClass(model.class));
+ return NO;
+}
++ (NSInteger)rowCountWithWhereFormat:(id)where, ...
+{
+ if ([where isKindOfClass:[NSString class]]) {
+ va_list list;
+ va_start(list, where);
+ where = [[NSString alloc] initWithFormat:where arguments:list];
+ va_end(list);
+ }
+ return [[self getUsingLKDBHelper] rowCount:self where:where];
+}
++ (NSInteger)rowCountWithWhere:(id)where, ...
+{
+ if ([where isKindOfClass:[NSString class]]) {
+ va_list list;
+ va_start(list, where);
+ where = [[NSString alloc] initWithFormat:where arguments:list];
+ va_end(list);
+ }
+ return [[self getUsingLKDBHelper] rowCount:self where:where];
+}
++ (NSMutableArray*)searchColumn:(id)columns where:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count
+{
+ return [[self getUsingLKDBHelper] search:self column:columns where:where orderBy:orderBy offset:offset count:count];
+}
++ (NSMutableArray*)searchWithWhere:(id)where orderBy:(NSString*)orderBy offset:(NSInteger)offset count:(NSInteger)count
+{
+ return [[self getUsingLKDBHelper] search:self where:where orderBy:orderBy offset:offset count:count];
+}
++ (NSMutableArray*)searchWithWhere:(id)where
+{
+ return [[self getUsingLKDBHelper] search:self where:where orderBy:nil offset:0 count:0];
+}
++ (NSMutableArray*)searchWithSQL:(NSString*)sql
+{
+ return [[self getUsingLKDBHelper] searchWithSQL:sql toClass:self];
+}
++ (id)searchSingleWithWhere:(id)where orderBy:(NSString*)orderBy
+{
+ return [[self getUsingLKDBHelper] searchSingle:self where:where orderBy:orderBy];
+}
+
++ (BOOL)insertToDB:(NSObject*)model
+{
+
+ if ([self checkModelClass:model]) {
+ return [[self getUsingLKDBHelper] insertToDB:model];
+ }
+ return NO;
+}
++ (BOOL)insertWhenNotExists:(NSObject*)model
+{
+ if ([self checkModelClass:model]) {
+ return [[self getUsingLKDBHelper] insertWhenNotExists:model];
+ }
+ return NO;
+}
++ (BOOL)updateToDB:(NSObject*)model where:(id)where, ...
+{
+ if ([self checkModelClass:model]) {
+ if ([where isKindOfClass:[NSString class]]) {
+ va_list list;
+ va_start(list, where);
+ where = [[NSString alloc] initWithFormat:where arguments:list];
+ va_end(list);
+ }
+ return [[self getUsingLKDBHelper] updateToDB:model where:where];
+ }
+ return NO;
+}
++ (BOOL)updateToDBWithSet:(NSString*)sets where:(id)where, ...
+{
+ if ([where isKindOfClass:[NSString class]]) {
+ va_list list;
+ va_start(list, where);
+ where = [[NSString alloc] initWithFormat:where arguments:list];
+ va_end(list);
+ }
+ return [[self getUsingLKDBHelper] updateToDB:self set:sets where:where];
+}
++ (BOOL)deleteToDB:(NSObject*)model
+{
+ if ([self checkModelClass:model]) {
+ return [[self getUsingLKDBHelper] deleteToDB:model];
+ }
+ return NO;
+}
++ (BOOL)deleteWithWhere:(id)where, ...
+{
+ if ([where isKindOfClass:[NSString class]]) {
+ va_list list;
+ va_start(list, where);
+ where = [[NSString alloc] initWithFormat:where arguments:list];
+ va_end(list);
+ }
+ return [[self getUsingLKDBHelper] deleteWithClass:self where:where];
+}
++ (BOOL)isExistsWithModel:(NSObject*)model
+{
+ if ([self checkModelClass:model]) {
+ return [[self getUsingLKDBHelper] isExistsModel:model];
+ }
+ return NO;
+}
+
+- (BOOL)updateToDB
+{
+ if (self.rowid > 0) {
+ return [self.class updateToDB:self where:nil];
+ }
+ else {
+ return [self saveToDB];
+ }
+}
+- (BOOL)saveToDB
+{
+ return [self.class insertToDB:self];
+}
+- (BOOL)deleteToDB
+{
+ return [self.class deleteToDB:self];
+}
+- (BOOL)isExistsFromDB
+{
+ return [self.class isExistsWithModel:self];
+}
+
++ (void)insertArrayByAsyncToDB:(NSArray*)models
+{
+ [self insertArrayByAsyncToDB:models completed:nil];
+}
++ (void)insertArrayByAsyncToDB:(NSArray*)models completed:(void (^)(BOOL))completedBlock
+{
+ if (models.count > 0) {
+ dispatch_async(dispatch_get_global_queue(0, 0), ^{
+ [self insertToDBWithArray:models filter:nil completed:completedBlock];
+ });
+ }
+}
+
++ (void)insertToDBWithArray:(NSArray*)models filter:(void (^)(id model, BOOL inserted, BOOL* rollback))filter
+{
+ [self insertToDBWithArray:models filter:filter completed:nil];
+}
+
++ (void)insertToDBWithArray:(NSArray*)models filter:(void (^)(id model, BOOL inserted, BOOL* rollback))filter completed:(void (^)(BOOL))completedBlock
+{
+ __block BOOL allInserted = YES;
+ [[self getUsingLKDBHelper] executeForTransaction:^BOOL(LKDBHelper* helper) {
+ BOOL isRollback = NO;
+ for (int i = 0; i < models.count; i++) {
+ id obj = [models objectAtIndex:i];
+ BOOL inserted = [helper insertToDB:obj];
+ allInserted &= inserted;
+ if (filter) {
+ filter(obj, inserted, &isRollback);
+ }
+ if (isRollback) {
+ allInserted = NO;
+ break;
+ }
+ }
+ return (isRollback == NO);
+ }];
+
+ if (completedBlock) {
+ completedBlock(allInserted);
+ }
+}
+
+@end
\ No newline at end of file
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKModel.h b/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKModel.h
new file mode 100644
index 0000000..c05d5d8
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKModel.h
@@ -0,0 +1,140 @@
+//
+// NSObject+LKModel.h
+// LKDBHelper
+//
+// Created by LJH on 13-4-15.
+// Copyright (c) 2013年 ljh. All rights reserved.
+//
+
+#import
+#import
+
+@class LKDBProperty;
+@class LKModelInfos;
+@class LKDBHelper;
+
+#pragma mark - 表结构
+@interface NSObject (LKTabelStructure)
+
+/**
+ * overwrite in your models(option)
+ *
+ * @return # table name #
+ */
++ (NSString*)getTableName;
+
+/**
+ * if you set it will use it as a table name
+ */
+@property (copy, nonatomic) NSString* db_tableName;
+
+/**
+ * the model is inserting ..
+ */
+@property (readonly, nonatomic) BOOL db_inserting;
+
+/**
+ * sqlite comes with rowid
+ */
+@property NSInteger rowid;
+
+/**
+ * overwrite in your models, if your table has primary key
+
+ * 主键列名 如果rowid<0 则跟据此名称update 和delete
+
+ * @return # column name #
+ */
++ (NSString*)getPrimaryKey;
+
+/**
+ * multi primary key
+ * 联合主键
+ * @return
+ */
++ (NSArray*)getPrimaryKeyUnionArray;
+
+/**
+ * overwrite in your models set column attribute
+ *
+ * @param property infos
+ */
++ (void)columnAttributeWithProperty:(LKDBProperty*)property;
+
+/**
+ * @brief get saved pictures and data file path,can overwirte
+
+ 获取保存的 图片和数据的文件路径
+ */
++ (NSString*)getDBImagePathWithName:(NSString*)filename;
++ (NSString*)getDBDataPathWithName:(NSString*)filename;
+@end
+
+#pragma mark - 表数据操作
+@interface NSObject (LKTableData)
+
+/***
+ * @brief overwrite in your models,return insert sqlite table data
+ *
+ *
+ * @return property the data after conversion
+ */
+- (id)userGetValueForModel:(LKDBProperty*)property;
+
+/***
+ * @brief overwrite in your models,return insert sqlite table data
+ *
+ * @param property will set property
+ * @param value sqlite value (NSString(NSData UTF8 Coding) or NSData)
+ */
+- (void)userSetValueForModel:(LKDBProperty*)property value:(id)value;
+
+///overwrite
++ (NSDateFormatter*)getModelDateFormatter;
+
+//lkdbhelper use
+- (id)modelGetValue:(LKDBProperty*)property;
+- (void)modelSetValue:(LKDBProperty*)property value:(id)value;
+
+- (id)singlePrimaryKeyValue;
+- (BOOL)singlePrimaryKeyValueIsEmpty;
+- (LKDBProperty*)singlePrimaryKeyProperty;
++ (NSString*)db_rowidAliasName;
+@end
+
+@interface NSObject (LKModel)
+
+/**
+ * return model use LKDBHelper , default return global LKDBHelper;
+ *
+ * @return LKDBHelper
+ */
++ (LKDBHelper*)getUsingLKDBHelper;
+
+/**
+ * class attributes
+ *
+ * @return LKModelInfos
+ */
++ (LKModelInfos*)getModelInfos;
+
+/**
+ * @brief Containing the super class attributes 设置是否包含 父类 的属性
+ */
++ (BOOL)isContainParent;
+
+/**
+ * 当前表中的列是否包含自身的属性。
+ *
+ * @return BOOL
+ */
++ (BOOL)isContainSelf;
+
+/**
+ * @brief log all property 打印所有的属性名称和数据
+ */
+- (NSString*)printAllPropertys;
+- (NSString*)printAllPropertysIsContainParent:(BOOL)containParent;
+
+- (NSMutableString*)getAllPropertysString;
+@end
\ No newline at end of file
diff --git a/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKModel.m b/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKModel.m
new file mode 100644
index 0000000..13bc8eb
--- /dev/null
+++ b/ios/Pods/LKDBHelper/LKDBHelper/Helper/NSObject+LKModel.m
@@ -0,0 +1,934 @@
+//
+// NSObject+LKModel.m
+// LKDBHelper
+//
+// Created by LJH on 13-4-15.
+// Copyright (c) 2013年 ljh. All rights reserved.
+//
+
+#import "NSObject+LKModel.h"
+#import "LKDBHelper.h"
+
+#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
+#import
+#define LKDBImage UIImage
+#define LKDBColor UIColor
+#else
+#import
+#define LKDBImage NSImage
+#define LKDBColor NSColor
+#endif
+
+static char LKModelBase_Key_RowID;
+static char LKModelBase_Key_TableName;
+static char LKModelBase_Key_Inserting;
+
+@implementation NSObject (LKModel)
+
++ (LKDBHelper*)getUsingLKDBHelper
+{
+ ///ios8 能获取系统类的属性了 所以没有办法判断属性数量来区分自定义类和系统类
+ ///可能系统类的存取会不正确
+ static LKDBHelper* helper;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ helper = [[LKDBHelper alloc] init];
+ });
+ return helper;
+}
+#pragma mark Tabel Structure Function 表结构
++ (NSString*)getTableName
+{
+ return NSStringFromClass(self);
+}
+
++ (NSString*)getPrimaryKey
+{
+ return @"rowid";
+}
+
++ (NSArray*)getPrimaryKeyUnionArray
+{
+ return nil;
+}
+
++ (void)columnAttributeWithProperty:(LKDBProperty*)property
+{
+ //overwrite
+}
+#pragma 属性
+- (void)setRowid:(NSInteger)rowid
+{
+ objc_setAssociatedObject(self, &LKModelBase_Key_RowID, [NSNumber numberWithInteger:rowid], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+- (NSInteger)rowid
+{
+ return [objc_getAssociatedObject(self, &LKModelBase_Key_RowID) integerValue];
+}
+
+- (void)setDb_tableName:(NSString*)db_tableName
+{
+ objc_setAssociatedObject(self, &LKModelBase_Key_TableName, db_tableName, OBJC_ASSOCIATION_COPY_NONATOMIC);
+}
+- (NSString*)db_tableName
+{
+ NSString* tableName = objc_getAssociatedObject(self, &LKModelBase_Key_TableName);
+ if (tableName.length == 0) {
+ tableName = [self.class getTableName];
+ }
+ return tableName;
+}
+- (BOOL)db_inserting
+{
+ return [objc_getAssociatedObject(self, &LKModelBase_Key_Inserting) boolValue];
+}
+- (void)setDb_inserting:(BOOL)db_inserting
+{
+ NSNumber* number = nil;
+ if (db_inserting) {
+ number = [NSNumber numberWithBool:YES];
+ }
+ objc_setAssociatedObject(self, &LKModelBase_Key_Inserting, number, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+#pragma 无关紧要的
++ (NSString*)getDBImagePathWithName:(NSString*)filename
+{
+ NSString* dir = [NSString stringWithFormat:@"dbimg/%@", NSStringFromClass(self)];
+ return [LKDBUtils getPathForDocuments:filename inDir:dir];
+}
++ (NSString*)getDBDataPathWithName:(NSString*)filename
+{
+ NSString* dir = [NSString stringWithFormat:@"dbdata/%@", NSStringFromClass(self)];
+ return [LKDBUtils getPathForDocuments:filename inDir:dir];
+}
++ (NSDictionary*)getTableMapping
+{
+ return nil;
+}
+#pragma mark - Table Data Function 表数据
++ (NSDateFormatter*)getModelDateFormatter
+{
+ return nil;
+}
+
+///get
+- (id)modelGetValue:(LKDBProperty*)property
+{
+ id value = [self valueForKey:property.propertyName];
+ id returnValue = value;
+ if (value == nil) {
+ return nil;
+ }
+ else if ([value isKindOfClass:[NSString class]]) {
+ returnValue = value;
+ }
+ else if ([value isKindOfClass:[NSNumber class]]) {
+ returnValue = [[LKDBUtils numberFormatter] stringFromNumber:value];
+ }
+ else if ([value isKindOfClass:[NSDate class]]) {
+ NSDateFormatter* formatter = [self.class getModelDateFormatter];
+ if (formatter) {
+ returnValue = [formatter stringFromDate:value];
+ }
+ else {
+ returnValue = [LKDBUtils stringWithDate:value];
+ }
+ returnValue = [returnValue stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ }
+ else if ([value isKindOfClass:[LKDBColor class]]) {
+ LKDBColor* color = value;
+ CGFloat r, g, b, a;
+ [color getRed:&r green:&g blue:&b alpha:&a];
+ returnValue = [NSString stringWithFormat:@"%.3f,%.3f,%.3f,%.3f", r, g, b, a];
+ }
+ else if ([value isKindOfClass:[NSValue class]]) {
+ NSString* columnType = property.propertyType;
+#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
+ if ([columnType isEqualToString:@"CGRect"]) {
+ returnValue = NSStringFromCGRect([value CGRectValue]);
+ }
+ else if ([columnType isEqualToString:@"CGPoint"]) {
+ returnValue = NSStringFromCGPoint([value CGPointValue]);
+ }
+ else if ([columnType isEqualToString:@"CGSize"]) {
+ returnValue = NSStringFromCGSize([value CGSizeValue]);
+ }
+ else if ([columnType isEqualToString:@"_NSRange"]) {
+ returnValue = NSStringFromRange([value rangeValue]);
+ }
+#else
+ if ([columnType hasSuffix:@"Rect"]) {
+ returnValue = NSStringFromRect([value rectValue]);
+ }
+ else if ([columnType hasSuffix:@"Point"]) {
+ returnValue = NSStringFromPoint([value pointValue]);
+ }
+ else if ([columnType hasSuffix:@"Size"]) {
+ returnValue = NSStringFromSize([value sizeValue]);
+ }
+ else if ([columnType hasSuffix:@"Range"]) {
+ returnValue = NSStringFromRange([value rangeValue]);
+ }
+#endif
+ }
+ else if ([value isKindOfClass:[LKDBImage class]]) {
+ long random = arc4random();
+ long date = [[NSDate date] timeIntervalSince1970];
+ NSString* filename = [NSString stringWithFormat:@"img%ld%ld", date & 0xFFFFF, random & 0xFFF];
+
+#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
+ NSData* datas = UIImageJPEGRepresentation(value, 1);
+#else
+ [value lockFocus];
+ NSBitmapImageRep* srcImageRep = [NSBitmapImageRep imageRepWithData:[value TIFFRepresentation]];
+ NSData* datas = [srcImageRep representationUsingType:NSJPEGFileType properties:@{}];
+ [value unlockFocus];
+#endif
+ [datas writeToFile:[self.class getDBImagePathWithName:filename]
+ atomically:YES];
+
+ returnValue = filename;
+ }
+ else if ([value isKindOfClass:[NSData class]]) {
+ long random = arc4random();
+ long date = [[NSDate date] timeIntervalSince1970];
+ NSString* filename = [NSString stringWithFormat:@"data%ld%ld", date & 0xFFFFF, random & 0xFFF];
+
+ [value writeToFile:[self.class getDBDataPathWithName:filename] atomically:YES];
+
+ returnValue = filename;
+ }
+ else {
+ if ([value isKindOfClass:[NSArray class]]) {
+ returnValue = [self db_jsonObjectFromArray:value];
+ }
+ else if ([value isKindOfClass:[NSDictionary class]]) {
+ returnValue = [self db_jsonObjectFromDictionary:value];
+ }
+ else {
+ returnValue = [self db_jsonObjectFromModel:value];
+ }
+ returnValue = [self db_jsonStringFromObject:returnValue];
+ }
+
+ return returnValue;
+}
+
+///set
+- (void)modelSetValue:(LKDBProperty*)property value:(id)value
+{
+ ///参试获取属性的Class
+ Class columnClass = NSClassFromString(property.propertyType);
+
+ id modelValue = nil;
+
+ if (columnClass == nil) {
+ ///当找不到 class 时,就是 基础类型 int,float CGRect 之类的
+
+ NSString* columnType = property.propertyType;
+ if ([LKSQL_Convert_FloatType rangeOfString:columnType].location != NSNotFound) {
+ modelValue = [[LKDBUtils numberFormatter] numberFromString:value];
+ }
+ else if ([LKSQL_Convert_IntType rangeOfString:columnType].location != NSNotFound) {
+ modelValue = [[LKDBUtils numberFormatter] numberFromString:value];
+ }
+#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
+ else if ([columnType isEqualToString:@"CGRect"]) {
+ CGRect rect = CGRectFromString(value);
+ modelValue = [NSValue valueWithCGRect:rect];
+ }
+ else if ([columnType isEqualToString:@"CGPoint"]) {
+ CGPoint point = CGPointFromString(value);
+ modelValue = [NSValue valueWithCGPoint:point];
+ }
+ else if ([columnType isEqualToString:@"CGSize"]) {
+ CGSize size = CGSizeFromString(value);
+ modelValue = [NSValue valueWithCGSize:size];
+ }
+ else if ([columnType isEqualToString:@"_NSRange"]) {
+ NSRange range = NSRangeFromString(value);
+ modelValue = [NSValue valueWithRange:range];
+ }
+#else
+ else if ([columnType hasSuffix:@"Rect"]) {
+ NSRect rect = NSRectFromString(value);
+ modelValue = [NSValue valueWithRect:rect];
+ }
+ else if ([columnType hasSuffix:@"Point"]) {
+ NSPoint point = NSPointFromString(value);
+ modelValue = [NSValue valueWithPoint:point];
+ }
+ else if ([columnType hasSuffix:@"Size"]) {
+ NSSize size = NSSizeFromString(value);
+ modelValue = [NSValue valueWithSize:size];
+ }
+ else if ([columnType hasSuffix:@"Range"]) {
+ NSRange range = NSRangeFromString(value);
+ modelValue = [NSValue valueWithRange:range];
+ }
+#endif
+ ///如果都没有值 默认给个0
+ if (modelValue == nil) {
+ modelValue = [NSNumber numberWithInt:0];
+ }
+ }
+ else if ([value length] == 0) {
+ //为了不继续遍历
+ }
+ else if ([columnClass isSubclassOfClass:[NSString class]]) {
+ modelValue = value;
+ }
+ else if ([columnClass isSubclassOfClass:[NSNumber class]]) {
+ modelValue = [[LKDBUtils numberFormatter] numberFromString:value];
+ }
+ else if ([columnClass isSubclassOfClass:[NSDate class]]) {
+ NSString* datestr = [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ NSDateFormatter* formatter = [self.class getModelDateFormatter];
+ if (formatter) {
+ modelValue = [formatter dateFromString:datestr];
+ }
+ else {
+ modelValue = [LKDBUtils dateWithString:datestr];
+ }
+ }
+ else if ([columnClass isSubclassOfClass:[LKDBColor class]]) {
+ NSString* color = value;
+ NSArray* array = [color componentsSeparatedByString:@","];
+ float r, g, b, a;
+ r = [[array objectAtIndex:0] floatValue];
+ g = [[array objectAtIndex:1] floatValue];
+ b = [[array objectAtIndex:2] floatValue];
+ a = [[array objectAtIndex:3] floatValue];
+
+ modelValue = [LKDBColor colorWithRed:r green:g blue:b alpha:a];
+ }
+ else if ([columnClass isSubclassOfClass:[LKDBImage class]]) {
+ NSString* filename = value;
+ NSString* filepath = [self.class getDBImagePathWithName:filename];
+ if ([LKDBUtils isFileExists:filepath]) {
+ LKDBImage* img = [[LKDBImage alloc] initWithContentsOfFile:filepath];
+ modelValue = img;
+ }
+ else {
+ modelValue = nil;
+ }
+ }
+ else if ([columnClass isSubclassOfClass:[NSData class]]) {
+ NSString* filename = value;
+ NSString* filepath = [self.class getDBDataPathWithName:filename];
+ if ([LKDBUtils isFileExists:filepath]) {
+ NSData* data = [NSData dataWithContentsOfFile:filepath];
+ modelValue = data;
+ }
+ else {
+ modelValue = nil;
+ }
+ }
+ else {
+ modelValue = [self db_modelWithJsonValue:value];
+ if ([modelValue isKindOfClass:columnClass] == NO) {
+ modelValue = nil;
+ }
+ }
+
+ [self setValue:modelValue forKey:property.propertyName];
+}
+#pragma mark - 对 model NSArray NSDictionary 进行支持
+- (id)db_jsonObjectFromDictionary:(NSDictionary*)dic
+{
+ if ([NSJSONSerialization isValidJSONObject:dic]) {
+ NSDictionary* bomb = @{ LKDB_TypeKey : LKDB_TypeKey_JSON, LKDB_ValueKey : dic };
+ return bomb;
+ }
+ else {
+ NSMutableDictionary* toDic = [NSMutableDictionary dictionary];
+ NSArray* allKeys = dic.allKeys;
+ for (NSInteger i = 0; i < allKeys.count; i++) {
+ NSString* key = [allKeys objectAtIndex:i];
+ id obj = [dic objectForKey:key];
+ id jsonObject = [self db_jsonObjectWithObject:obj];
+ if (jsonObject) {
+ [toDic setObject:jsonObject forKey:key];
+ }
+ }
+
+ if (toDic.count) {
+ NSDictionary* bomb = @{ LKDB_TypeKey : LKDB_TypeKey_Combo, LKDB_ValueKey : toDic };
+ return bomb;
+ }
+ }
+ return nil;
+}
+- (id)db_jsonObjectFromArray:(NSArray*)array
+{
+ if ([NSJSONSerialization isValidJSONObject:array]) {
+ NSDictionary* bomb = @{ LKDB_TypeKey : LKDB_TypeKey_JSON, LKDB_ValueKey : array };
+ return bomb;
+ }
+ else {
+ NSMutableArray* toArray = [NSMutableArray array];
+ NSInteger count = array.count;
+ for (NSInteger i = 0; i < count; i++) {
+ id obj = [array objectAtIndex:i];
+ id jsonObject = [self db_jsonObjectWithObject:obj];
+ if (jsonObject) {
+ [toArray addObject:jsonObject];
+ }
+ }
+
+ if (toArray.count) {
+ NSDictionary* bomb = @{ LKDB_TypeKey : LKDB_TypeKey_Combo, LKDB_ValueKey : toArray };
+ return bomb;
+ }
+ }
+ return nil;
+}
+///目前只支持 model、NSString、NSNumber 简单类型
+- (id)db_jsonObjectWithObject:(id)obj
+{
+ id jsonObject = nil;
+ if ([obj isKindOfClass:[NSString class]] || [obj isKindOfClass:[NSNumber class]]) {
+ jsonObject = obj;
+ }
+ else if ([obj isKindOfClass:[NSDate class]]) {
+ NSString* dateString = nil;
+ NSDateFormatter* formatter = [self.class getModelDateFormatter];
+ if (formatter) {
+ dateString = [formatter stringFromDate:obj];
+ }
+ else {
+ dateString = [LKDBUtils stringWithDate:obj];
+ }
+ dateString = [dateString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ if (dateString.length > 0) {
+ jsonObject = @{ LKDB_TypeKey : LKDB_TypeKey_Date, LKDB_ValueKey : dateString };
+ }
+ }
+ else if ([obj isKindOfClass:[NSArray class]]) {
+ jsonObject = [self db_jsonObjectFromArray:obj];
+ }
+ else if ([obj isKindOfClass:[NSDictionary class]]) {
+ jsonObject = [self db_jsonObjectFromArray:obj];
+ }
+ else {
+ jsonObject = [self db_jsonObjectFromModel:obj];
+ }
+
+ if (jsonObject == nil) {
+ jsonObject = [obj description];
+ }
+ return jsonObject;
+}
+
+- (id)db_jsonObjectFromModel:(NSObject*)model
+{
+ Class clazz = model.class;
+ NSDictionary* jsonObject = nil;
+ if (model.rowid > 0) {
+ [model updateToDB];
+ jsonObject = [self db_readInfoWithModel:model class:clazz];
+ }
+ else {
+ if (model.db_inserting == NO && [clazz getModelInfos] > 0) {
+ BOOL success = [model saveToDB];
+ if (success) {
+ jsonObject = [self db_readInfoWithModel:model class:clazz];
+ }
+ }
+ else {
+ NSAssert(NO, @"目前LKDB 还不支持 循环引用。 比如 A 持有 B, B 持有 A,这种的存储");
+ }
+ }
+ return jsonObject;
+}
+- (NSDictionary*)db_readInfoWithModel:(NSObject*)model class:(Class)clazz
+{
+ NSMutableDictionary* jsonObject = [NSMutableDictionary dictionary];
+ [jsonObject setObject:LKDB_TypeKey_Model forKey:LKDB_TypeKey];
+ [jsonObject setObject:model.db_tableName forKey:LKDB_TableNameKey];
+ [jsonObject setObject:NSStringFromClass(clazz) forKey:LKDB_ClassKey];
+ [jsonObject setObject:@(model.rowid) forKey:LKDB_RowIdKey];
+
+ NSDictionary* dic = [model db_getPrimaryKeysValues];
+ if (dic.count > 0 && [NSJSONSerialization isValidJSONObject:dic]) {
+ [jsonObject setObject:dic forKey:LKDB_PValueKey];
+ }
+ return jsonObject;
+}
+
+- (NSString*)db_jsonStringFromObject:(NSObject*)jsonObject
+{
+ if (jsonObject && [NSJSONSerialization isValidJSONObject:jsonObject]) {
+ NSData* data = [NSJSONSerialization dataWithJSONObject:jsonObject options:0 error:nil];
+ if (data.length > 0) {
+ NSString* jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
+ return jsonString;
+ }
+ }
+ return nil;
+}
+- (id)db_modelWithJsonValue:(id)value
+{
+ NSData* jsonData = nil;
+ if ([value isKindOfClass:[NSString class]]) {
+ jsonData = [value dataUsingEncoding:NSUTF8StringEncoding];
+ }
+ else if ([value isKindOfClass:[NSData class]]) {
+ jsonData = value;
+ }
+
+ if (jsonData.length > 0) {
+ NSDictionary* jsonDic = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:nil];
+ return [self db_objectWithDictionary:jsonDic];
+ }
+ return nil;
+}
+- (id)db_objectWithArray:(NSArray*)array
+{
+ NSMutableArray* toArray = nil;
+
+ NSInteger count = array.count;
+ for (NSInteger i = 0; i < count; i++) {
+ id value = [array objectAtIndex:i];
+ if ([value isKindOfClass:[NSDictionary class]]) {
+ value = [self db_objectWithDictionary:value];
+ }
+ else if ([value isKindOfClass:[NSArray class]]) {
+ value = [self db_objectWithArray:value];
+ }
+
+ if (value) {
+ if (toArray == nil) {
+ toArray = [NSMutableArray array];
+ }
+ [toArray addObject:value];
+ }
+ }
+
+ return toArray;
+}
+- (id)db_objectWithDictionary:(NSDictionary*)dic
+{
+ if (dic.count == 0) {
+ return nil;
+ }
+ NSString* type = [dic objectForKey:LKDB_TypeKey];
+ if (type) {
+ if ([type isEqualToString:LKDB_TypeKey_Model]) {
+ Class clazz = NSClassFromString([dic objectForKey:LKDB_ClassKey]);
+ NSInteger rowid = [[dic objectForKey:LKDB_RowIdKey] integerValue];
+ NSString* tableName = [dic objectForKey:LKDB_TableNameKey];
+
+ NSString* where = nil;
+
+ NSString* rowCountWhere = [NSString stringWithFormat:@"select count(rowid) from %@ where rowid=%ld limit 1", tableName, (long)rowid];
+ NSInteger result = [[[clazz getUsingLKDBHelper] executeScalarWithSQL:rowCountWhere arguments:nil] integerValue];
+ if (result > 0) {
+ where = [NSString stringWithFormat:@"select rowid,* from %@ where rowid=%ld limit 1", tableName, (long)rowid];
+ }
+ else {
+ NSDictionary* pv = [dic objectForKey:LKDB_PValueKey];
+ if (pv.count > 0) {
+ BOOL isNeedAddDot = NO;
+ NSMutableString* sb = [NSMutableString stringWithFormat:@"select rowid,* from %@ where", tableName];
+
+ NSArray* allKeys = pv.allKeys;
+ for (NSString* key in allKeys) {
+ id obj = [pv objectForKey:key];
+ if (isNeedAddDot) {
+ [sb appendString:@" and"];
+ }
+ [sb appendFormat:@" %@ = '%@'", key, obj];
+
+ isNeedAddDot = YES;
+ }
+
+ [sb appendString:@" limit 1"];
+
+ where = [NSString stringWithString:sb];
+ }
+ }
+
+ if (where) {
+ NSArray* array = [[clazz getUsingLKDBHelper] searchWithSQL:where toClass:clazz];
+ if (array.count > 0) {
+ NSObject* result = [array objectAtIndex:0];
+ result.db_tableName = tableName;
+ return result;
+ }
+ }
+ }
+ else if ([type isEqualToString:LKDB_TypeKey_JSON]) {
+ id value = [dic objectForKey:LKDB_ValueKey];
+ return value;
+ }
+ else if ([type isEqualToString:LKDB_TypeKey_Combo]) {
+ id value = [dic objectForKey:LKDB_ValueKey];
+ if ([value isKindOfClass:[NSArray class]]) {
+ return [self db_objectWithArray:value];
+ }
+ else if ([value isKindOfClass:[NSDictionary class]]) {
+ return [self db_objectWithDictionary:value];
+ }
+ else {
+ return value;
+ }
+ }
+ else if ([type isEqualToString:LKDB_TypeKey_Date]) {
+ NSString* datestr = [dic objectForKey:LKDB_ValueKey];
+ NSDateFormatter* formatter = [self.class getModelDateFormatter];
+ if (formatter) {
+ return [formatter dateFromString:datestr];
+ }
+ else {
+ return [LKDBUtils dateWithString:datestr];
+ }
+ }
+ }
+ else {
+ NSArray* allKeys = dic.allKeys;
+ NSMutableDictionary* toDic = [NSMutableDictionary dictionary];
+ for (NSInteger i = 0; i < allKeys.count; i++) {
+ NSString* key = [allKeys objectAtIndex:i];
+ id value = [dic objectForKey:key];
+
+ id saveObj = value;
+ if ([value isKindOfClass:[NSArray class]]) {
+ saveObj = [self db_objectWithArray:value];
+ }
+ else if ([value isKindOfClass:[NSDictionary class]]) {
+ saveObj = [self db_objectWithDictionary:value];
+ }
+
+ if (saveObj) {
+ [toDic setObject:saveObj forKey:key];
+ }
+ }
+ return toDic;
+ }
+ return nil;
+}
+#pragma mark - your can overwrite
+- (void)setNilValueForKey:(NSString*)key
+{
+ NSLog(@"nil 这种设置到了 int 等基础类型中");
+}
+- (id)valueForUndefinedKey:(NSString*)key
+{
+ NSLog(@"你有get方法没实现,key:%@", key);
+ return nil;
+}
+- (void)setValue:(id)value forUndefinedKey:(NSString*)key
+{
+ NSLog(@"你有set方法没实现,key:%@", key);
+}
+
+#pragma mark -
+- (void)userSetValueForModel:(LKDBProperty*)property value:(id)value
+{
+}
+- (id)userGetValueForModel:(LKDBProperty*)property
+{
+ return nil;
+}
+
+- (NSDictionary*)db_getPrimaryKeysValues
+{
+ LKModelInfos* infos = [self.class getModelInfos];
+ NSArray* array = infos.primaryKeys;
+ NSMutableDictionary* dic = [NSMutableDictionary dictionary];
+ for (NSString* pname in array) {
+ LKDBProperty* property = [infos objectWithSqlColumnName:pname];
+ id value = nil;
+ if ([property.type isEqualToString:LKSQL_Mapping_UserCalculate]) {
+ value = [self userGetValueForModel:property];
+ }
+ else {
+ value = [self modelGetValue:property];
+ }
+ if (value) {
+ [dic setObject:value forKey:property.sqlColumnName];
+ }
+ }
+ return dic;
+}
+//主键值 是否为空
+- (BOOL)singlePrimaryKeyValueIsEmpty
+{
+ LKDBProperty* property = [self singlePrimaryKeyProperty];
+ if (property) {
+ id pkvalue = [self singlePrimaryKeyValue];
+ if ([property.sqlColumnType isEqualToString:LKSQL_Type_Int]) {
+ if ([pkvalue isKindOfClass:[NSString class]]) {
+ if ([LKDBUtils checkStringIsEmpty:pkvalue])
+ return YES;
+
+ if ([pkvalue integerValue] == 0)
+ return YES;
+
+ return NO;
+ }
+ if ([pkvalue isKindOfClass:[NSNumber class]]) {
+ if ([pkvalue integerValue] == 0)
+ return YES;
+ else
+ return NO;
+ }
+ return YES;
+ }
+ else {
+ return (pkvalue == nil);
+ }
+ }
+ return NO;
+}
+- (LKDBProperty*)singlePrimaryKeyProperty
+{
+ LKModelInfos* infos = [self.class getModelInfos];
+ if (infos.primaryKeys.count == 1) {
+ NSString* name = [infos.primaryKeys objectAtIndex:0];
+ return [infos objectWithSqlColumnName:name];
+ }
+ return nil;
+}
+- (id)singlePrimaryKeyValue
+{
+ LKDBProperty* property = [self singlePrimaryKeyProperty];
+ if (property) {
+ if ([property.type isEqualToString:LKSQL_Mapping_UserCalculate]) {
+ return [self userGetValueForModel:property];
+ }
+ else {
+ return [self modelGetValue:property];
+ }
+ }
+ return nil;
+}
++ (NSString*)db_rowidAliasName
+{
+ LKModelInfos* infos = [self getModelInfos];
+ if (infos.primaryKeys.count == 1) {
+ NSString* primaryType = [infos objectWithSqlColumnName:[infos.primaryKeys lastObject]].sqlColumnType;
+ if ([primaryType isEqualToString:LKSQL_Type_Int]) {
+ return [infos.primaryKeys lastObject];
+ }
+ }
+ return nil;
+}
+
+#pragma mark - get model property info
++ (LKModelInfos*)getModelInfos
+{
+ static __strong NSMutableDictionary* oncePropertyDic;
+ static __strong NSRecursiveLock* lock;
+
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ lock = [[NSRecursiveLock alloc] init];
+ oncePropertyDic = [[NSMutableDictionary alloc] initWithCapacity:8];
+ });
+
+ LKModelInfos* infos;
+ [lock lock];
+
+ infos = [oncePropertyDic objectForKey:NSStringFromClass(self)];
+ if (infos == nil) {
+ NSMutableArray* pronames = [NSMutableArray array];
+ NSMutableArray* protypes = [NSMutableArray array];
+ NSDictionary* keymapping = [self getTableMapping];
+
+ if ([self isContainSelf] && [self class] != [NSObject class]) {
+ [self getSelfPropertys:pronames protypes:protypes];
+ }
+
+ NSArray* pkArray = [self getPrimaryKeyUnionArray];
+ if (pkArray.count == 0) {
+ pkArray = nil;
+ NSString* pk = [self getPrimaryKey];
+ if ([LKDBUtils checkStringIsEmpty:pk] == NO) {
+ pkArray = [NSArray arrayWithObject:pk];
+ }
+ }
+ if ([self isContainParent] && [self superclass] != [NSObject class]) {
+ LKModelInfos* superInfos = [[self superclass] getModelInfos];
+ for (NSInteger i = 0; i < superInfos.count; i++) {
+ LKDBProperty* db_p = [superInfos objectWithIndex:i];
+ if (db_p.propertyName && db_p.propertyType && [db_p.propertyName isEqualToString:@"rowid"] == NO) {
+ [pronames addObject:db_p.propertyName];
+ [protypes addObject:db_p.propertyType];
+ }
+ }
+ }
+ if (pronames.count > 0) {
+ infos = [[LKModelInfos alloc] initWithKeyMapping:keymapping propertyNames:pronames propertyType:protypes primaryKeys:pkArray];
+ }
+ else {
+ infos = [[LKModelInfos alloc] init];
+ }
+
+ [oncePropertyDic setObject:infos forKey:NSStringFromClass(self)];
+ }
+
+ [lock unlock];
+ return infos;
+}
+
++ (BOOL)isContainParent
+{
+ return NO;
+}
+
++ (BOOL)isContainSelf
+{
+ return YES;
+}
+
+/**
+ * @brief 获取自身的属性
+ *
+ * @param pronames 保存属性名称
+ * @param protypes 保存属性类型
+ */
++ (void)getSelfPropertys:(NSMutableArray*)pronames protypes:(NSMutableArray*)protypes
+{
+ unsigned int outCount = 0, i = 0;
+ objc_property_t* properties = class_copyPropertyList(self, &outCount);
+
+ for (i = 0; i < outCount; i++) {
+ objc_property_t property = properties[i];
+ NSString* propertyName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
+
+ //取消rowid 的插入 //子类 已重载的属性 取消插入
+ if (propertyName.length == 0 || [propertyName isEqualToString:@"rowid"] ||
+ [pronames indexOfObject:propertyName] != NSNotFound) {
+ continue;
+ }
+ NSString* propertyType = [NSString stringWithCString:property_getAttributes(property) encoding:NSUTF8StringEncoding];
+
+ ///过滤只读属性
+ if ([propertyType rangeOfString:@",R,"].length > 0 || [propertyType hasSuffix:@",R"]) {
+ NSString* firstWord = [[propertyName substringToIndex:1] uppercaseString];
+ NSString* otherWord = [propertyName substringFromIndex:1];
+ NSString* setMethodString = [NSString stringWithFormat:@"set%@%@:", firstWord, otherWord];
+ SEL setSEL = NSSelectorFromString(setMethodString);
+ ///有set方法就不过滤了
+ if ([self instancesRespondToSelector:setSEL] == NO) {
+ continue;
+ }
+ }
+
+ /*
+ c char
+ i int
+ l long
+ s short
+ d double
+ f float
+ @ id //指针 对象
+ ... BOOL 获取到的表示 方式是 char
+ .... ^i 表示 int* 一般都不会用到
+ */
+
+ NSString* propertyClassName = nil;
+ if ([propertyType hasPrefix:@"T@"]) {
+
+ NSRange range = [propertyType rangeOfString:@","];
+ if (range.location > 4 && range.location <= propertyType.length) {
+ range = NSMakeRange(3, range.location - 4);
+ propertyClassName = [propertyType substringWithRange:range];
+ if ([propertyClassName hasSuffix:@">"]) {
+ NSRange categoryRange = [propertyClassName rangeOfString:@"<"];
+ if (categoryRange.length > 0) {
+ propertyClassName = [propertyClassName substringToIndex:categoryRange.location];
+ }
+ }
+ }
+ }
+ else if ([propertyType hasPrefix:@"T{"]) {
+ NSRange range = [propertyType rangeOfString:@"="];
+ if (range.location > 2 && range.location <= propertyType.length) {
+ range = NSMakeRange(2, range.location - 2);
+ propertyClassName = [propertyType substringWithRange:range];
+ }
+ }
+ else {
+ propertyType = [propertyType lowercaseString];
+ if ([propertyType hasPrefix:@"ti"] || [propertyType hasPrefix:@"tb"]) {
+ propertyClassName = @"int";
+ }
+ else if ([propertyType hasPrefix:@"tf"]) {
+ propertyClassName = @"float";
+ }
+ else if ([propertyType hasPrefix:@"td"]) {
+ propertyClassName = @"double";
+ }
+ else if ([propertyType hasPrefix:@"tl"] || [propertyType hasPrefix:@"tq"]) {
+ propertyClassName = @"long";
+ }
+ else if ([propertyType hasPrefix:@"tc"]) {
+ propertyClassName = @"char";
+ }
+ else if ([propertyType hasPrefix:@"ts"]) {
+ propertyClassName = @"short";
+ }
+ }
+
+ if ([LKDBUtils checkStringIsEmpty:propertyClassName]) {
+ ///没找到具体的属性就放弃
+ continue;
+ }
+ ///添加属性
+ [pronames addObject:propertyName];
+ [protypes addObject:propertyClassName];
+ }
+ free(properties);
+ if ([self isContainParent] && [self superclass] != [NSObject class]) {
+ [[self superclass] getSelfPropertys:pronames protypes:protypes];
+ }
+}
+
+#pragma mark - log all property
+- (NSMutableString*)getAllPropertysString
+{
+ Class clazz = [self class];
+ NSMutableString* sb = [NSMutableString stringWithFormat:@"\n <%@> :\n", NSStringFromClass(clazz)];
+ [sb appendFormat:@"rowid : %ld\n", (long)self.rowid];
+ [self mutableString:sb appendPropertyStringWithClass:clazz containParent:YES];
+ return sb;
+}
+- (NSString*)printAllPropertys
+{
+ return [self printAllPropertysIsContainParent:NO];
+}
+- (NSString*)printAllPropertysIsContainParent:(BOOL)containParent
+{
+#ifdef DEBUG
+ Class clazz = [self class];
+ NSMutableString* sb = [NSMutableString stringWithFormat:@"\n <%@> :\n", NSStringFromClass(clazz)];
+ [sb appendFormat:@"rowid : %ld\n", (long)self.rowid];
+ [self mutableString:sb appendPropertyStringWithClass:clazz containParent:containParent];
+ NSLog(@"%@", sb);
+ return sb;
+#else
+ return @"";
+#endif
+}
+- (void)mutableString:(NSMutableString*)sb appendPropertyStringWithClass:(Class)clazz containParent:(BOOL)containParent
+{
+ if (clazz == [NSObject class]) {
+ return;
+ }
+ unsigned int outCount = 0, i = 0;
+ objc_property_t* properties = class_copyPropertyList(clazz, &outCount);
+ for (i = 0; i < outCount; i++) {
+ objc_property_t property = properties[i];
+ NSString* propertyName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
+ [sb appendFormat:@" %@ : %@ \n", propertyName, [self valueForKey:propertyName]];
+ }
+ free(properties);
+ if (containParent) {
+ [self mutableString:sb appendPropertyStringWithClass:clazz.superclass containParent:containParent];
+ }
+}
+
+@end
\ No newline at end of file
diff --git a/ios/Pods/LKDBHelper/README.md b/ios/Pods/LKDBHelper/README.md
new file mode 100644
index 0000000..107a7d9
--- /dev/null
+++ b/ios/Pods/LKDBHelper/README.md
@@ -0,0 +1,269 @@
+LKDBHelper
+====================================
+this is sqlite ORM (an automatic database operation)
+thread-safe and not afraid of recursive deadlock
+
+QQ群号 113767274 有什么问题或者改进的地方大家一起讨论
+
+推荐个 json 和 model 互转非常好用的工具类 https://github.com/dcty/YYJSON 作者是个大神级的人物
+支持 NSData 直接转换成 model array
+
+#Big Upgrade 2.0
+
+Supported __NSArray__,__NSDictionary__, __ModelClass__, __NSNumber__, __NSString__, __NSDate__, __NSData__, __UIColor__, __UIImage__, __CGRect__, __CGPoint__, __CGSize__, __NSRange__, __int__,__char__,__float__, __double__, __long__.. attribute to insert and select automation.
+
+全面支持 __NSArray__,__NSDictionary__, __ModelClass__, __NSNumber__, __NSString__, __NSDate__, __NSData__, __UIColor__, __UIImage__, __CGRect__, __CGPoint__, __CGSize__, __NSRange__, __int__,__char__,__float__, __double__, __long__.. 等属性的自动化操作(插入和查询)
+
+------------------------------------
+Requirements
+====================================
+
+* iOS 4.3+
+* ARC only
+* FMDB(https://github.com/ccgus/fmdb)
+
+##Adding to your project
+
+If you are using CocoaPods, then, just add this line to your PodFile
+
+```objective-c
+pod 'LKDBHelper', :head
+```
+
+If you are using Encryption, Order can not be wrong
+
+```objective-c
+pod 'FMDB/SQLCipher',:head
+pod 'LKDBHelper',:head
+```
+
+@property(strong,nonatomic)NSString* encryptionKey;
+
+##Basic usage
+
+1 . Create a new Objective-C class for your data model
+
+```objective-c
+@interface LKTest : NSObject
+@property(copy,nonatomic)NSString* name;
+@property NSUInteger age;
+@property BOOL isGirl;
+
+@property(strong,nonatomic)LKTestForeign* address;
+@property(strong,nonatomic)NSArray* blah;
+@property(strong,nonatomic)NSDictionary* hoho;
+
+@property char like;
+...
+```
+2 . in the *.m file, overwirte getTableName function (option)
+
+```objective-c
++(NSString *)getTableName
+{
+ return @"LKTestTable";
+}
+```
+3 . in the *.m file, overwirte callback function (option)
+
+```objective-c
+@interface NSObject(LKDBHelper_Delegate)
+
++(void)dbDidCreateTable:(LKDBHelper*)helper tableName:(NSString*)tableName;
++(void)dbDidAlterTable:(LKDBHelper*)helper tableName:(NSString*)tableName addColumns:(NSArray*)columns;
+
++(BOOL)dbWillInsert:(NSObject*)entity;
++(void)dbDidInserted:(NSObject*)entity result:(BOOL)result;
+
++(BOOL)dbWillUpdate:(NSObject*)entity;
++(void)dbDidUpdated:(NSObject*)entity result:(BOOL)result;
+
++(BOOL)dbWillDelete:(NSObject*)entity;
++(void)dbDidDeleted:(NSObject*)entity result:(BOOL)result;
+
+///data read finish
++(void)dbDidSeleted:(NSObject*)entity;
+
+@end
+
+```
+4 . Initialize your model with data and insert to database
+
+```objective-c
+ LKTestForeign* foreign = [[LKTestForeign alloc]init];
+ foreign.address = @":asdasdasdsadasdsdas";
+ foreign.postcode = 123341;
+ foreign.addid = 213214;
+
+ //插入数据 insert table row
+ LKTest* test = [[LKTest alloc]init];
+ test.name = @"zhan san";
+ test.age = 16;
+
+ //外键 foreign key
+ test.address = foreign;
+ test.blah = @[@"1",@"2",@"3"];
+ test.blah = @[@"0",@[@1],@{@"2":@2},foreign];
+ test.hoho = @{@"array":test.blah,@"foreign":foreign,@"normal":@123456,@"date":[NSDate date]};
+
+ //异步 插入第一条 数据 Insert the first
+ [test saveToDB];
+ //or
+ //[globalHelper insertToDB:test];
+
+```
+5 . select 、 delete 、 update 、 isExists 、 rowCount ...
+
+```objective-c
+ select:
+
+ NSMutableArray* array = [LKTest searchWithWhere:nil orderBy:nil offset:0 count:100];
+ for (id obj in arraySync) {
+ addText(@"%@",[obj printAllPropertys]);
+ }
+
+ delete:
+
+ [LKTest deleteToDB:test];
+
+ update:
+
+ test.name = "rename";
+ [LKTest updateToDB:test where:nil];
+
+ isExists:
+
+ [LKTest isExistsWithModel:test];
+
+ rowCount:
+
+ [LKTest rowCountWithWhere:nil];
+
+
+```
+6 . Description of parameters "where"
+
+```objective-c
+ For example:
+ single: @"rowid = 1" or @{@"rowid":@1}
+
+ more: @"rowid = 1 and sex = 0" or @{@"rowid":@1,@"sex":@0}
+
+ when where is "or" type , such as @"rowid = 1 or sex = 0"
+ you only use NSString
+
+ array: @"rowid in (1,2,3)" or @{@"rowid":@[@1,@2,@3]}
+
+ composite: @"rowid in (1,2,3) and sex=0 " or @{@"rowid":@[@1,@2,@3],@"sex":@0}
+
+ If you want to be judged , only use NSString
+ For example: @"date >= '2013-04-01 00:00:00'"
+```
+
+##table mapping
+
+overwirte getTableMapping Function (option)
+
+```objective-c
++(NSDictionary *)getTableMapping
+{
+ //return nil
+ return @{@"name":LKSQLInherit,
+ @"MyAge":@"age",
+ @"img":LKSQLInherit,
+ @"MyDate":@"date",
+ @"color":LKSQLInherit,
+ @"address":LKSQLUserCalculate};
+}
+```
+
+##table update (option)
+
+```objective-c
++(void)dbDidAlterTable:(LKDBHelper *)helper tableName:(NSString *)tableName addColumns:(NSArray *)columns
+{
+ for (int i=0; i '2000-01-01 00:00:00'";
+ property.length = 30;
+ }
+}
+```
+
+##demo screenshot
+
+
table test data
+
+
foreign key data
+
+
+----------
+Change-log
+==========
+
+**Version 1.1** @ 2012-6-20
+
+- automatic table mapping
+- support optional columns
+- support column attribute settings
+- you can return column content
+
+**Version 1.0** @ 2013-5-19
+
+- overwrite and rename LKDBHelper
+- property type support: UIColor,NSDate,UIImage,NSData,CGRect,CGSize,CGPoint,int,float,double,NSString,short,char,bool,NSInterger..
+- fix a recursive deadlock.
+- rewrite the asynchronous operation -
+- thread-safe
+- various bug modified optimize cache to improve performance
+- test and demos
+- bug fixes, speed improvements
+
+**Version 0.0.1** @ 2012-10-1
+
+- Initial release with LKDAOBase
+
+
+-------
+License
+=======
+
+This code is distributed under the terms and conditions of the MIT license.
+
+-------
+Contribution guidelines
+=======
+
+* if you are fixing a bug you discovered, please add also a unit test so I know how exactly to reproduce the bug before merging
+
+-------
+Contributors
+=======
+
+Author: Jianghuai Li
+
+Contributors: waiting for you to join
+
diff --git a/ios/Pods/Manifest.lock b/ios/Pods/Manifest.lock
new file mode 100644
index 0000000..e829489
--- /dev/null
+++ b/ios/Pods/Manifest.lock
@@ -0,0 +1,15 @@
+PODS:
+ - FMDB (2.6):
+ - FMDB/standard (= 2.6)
+ - FMDB/standard (2.6)
+ - LKDBHelper (2.1.8):
+ - FMDB
+
+DEPENDENCIES:
+ - LKDBHelper
+
+SPEC CHECKSUMS:
+ FMDB: c1968bab3ab0aed38f66cb778ae1e7fa9a652b6e
+ LKDBHelper: 1b55f67e44f34af8828b31aa36b36141fdde03a8
+
+COCOAPODS: 0.39.0
diff --git a/ios/Pods/Pods.xcodeproj/project.pbxproj b/ios/Pods/Pods.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..8ba3365
--- /dev/null
+++ b/ios/Pods/Pods.xcodeproj/project.pbxproj
@@ -0,0 +1,661 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 0050321B606BB2AD14A3FA5C0BCB7DC8 /* LKDBUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = AFCC279B2B823EB16199B9E263A89B26 /* LKDBUtils.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ 0EF8E9AA652DBE2745A7D5C8CD2E3BDE /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C9446B7DCE0B4CBF6063AC59AAFC11 /* FMDatabasePool.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ 0F8A8E0D6FAEBF758E0B4D620335F094 /* FMDatabasePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 32B4637969D4672AB662708E1B61828B /* FMDatabasePool.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 11B336E91CE118B99E33125F23E20BA9 /* LKDB+Mapping.h in Headers */ = {isa = PBXBuildFile; fileRef = B2ACEC59A336186134ECD748A783725A /* LKDB+Mapping.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 12B089D53EF77FC551CD25AD27B805FD /* NSObject+LKDBHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 661C328D0A44FF0F3C8727F15BE23F44 /* NSObject+LKDBHelper.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ 1FA39854D4CEF957A35DABFC4EE56BFC /* NSObject+LKModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A4222AB40D3E7DF76F0A4BEC7A76C52 /* NSObject+LKModel.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ 217CF9A8EB62F149658E7865882D1598 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */; };
+ 266F0CD3A0A86BF17CF44201A39DAAB0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */; };
+ 282081E035E7A843068E8BCC2E07C217 /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = A632AAF02C79C77A8D32A8A1D0A95436 /* FMDatabaseQueue.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ 313531CEDA0294311D87B4F4C3F073F4 /* FMDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 47CAE78BC5812E23FBC400D441F8BCB2 /* FMDB.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 3D0F69C4CA35EB6A1F686BA88B19B4F6 /* FMDB-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B107DC1588207AEB4CCE5B799B2290F /* FMDB-dummy.m */; };
+ 4A7C771B81E0B36DFB89AB6AE0A6C8AE /* Pods-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 272643F56613CA0D336AE3DBF19DC404 /* Pods-dummy.m */; };
+ 4C6AEE3AE764C0D9F09CFA0F58CA401D /* NSObject+LKDBHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 4EA9DA2D741BC470E0085B62B62A8731 /* NSObject+LKDBHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ 4D419D1E29614725D1515157C5262C78 /* LKDBHelper-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 83504F76B9E9F30F01FF5598259399CD /* LKDBHelper-dummy.m */; };
+ 56D7A9D7CD648F77F08402F80EC1EC41 /* LKDBHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 2DA18E47FA8251446CA04F937D58CC3D /* LKDBHelper.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ 587B76A3E381AF7C3EFFDF6754D39288 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */; };
+ A350C5704A1F233DAD830E081E00F8C1 /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = ED4E31DC0E75C1F49FB1EEBA4EC5F58D /* FMDatabaseAdditions.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ B2B08C521A8EF41B71F97B10EA026D12 /* LKDBUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 579F5ED8A0DAFD8C56FB430CB573C116 /* LKDBUtils.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ B418C9BDCF8C6BAC2E3942F157BB6D4C /* FMDatabaseAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = CF89E0700649464F25D39F4660E41E45 /* FMDatabaseAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ C76FBC312FDF3897164382CFA7D47206 /* LKDBHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F3846A9AF7C473F2763CB0BF83414B2 /* LKDBHelper.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ CA027706DD6805766F1F4EC548E72440 /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 9293ABD725A0136D97B401C9D051372F /* FMDatabase.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ D0C5FF5485EAA2CDA03E9796B407697A /* FMDatabaseQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D054E379E6286CB236EA45DEE5E4DD4 /* FMDatabaseQueue.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ D0D5FFE53407F16C9CD3D0ECF43ACE93 /* FMDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = D28F07DC9FB3BDEC709C3B761C381C8F /* FMDatabase.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ D55C7FDDC32FFC90257BC908F1D85026 /* LKDB+Mapping.m in Sources */ = {isa = PBXBuildFile; fileRef = D991A0D7A853849BD0F44613E61E1D0A /* LKDB+Mapping.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ DEFA3504695E9DFDE1177DAB22884470 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1C5CD724098DF351A8617144043B63 /* FMResultSet.m */; settings = {COMPILER_FLAGS = "-DOS_OBJECT_USE_OBJC=0"; }; };
+ F51DE617E72C6987AB8BBDFCA15EA414 /* NSObject+LKModel.h in Headers */ = {isa = PBXBuildFile; fileRef = 842E99FC17A34EE232578016F97C9B43 /* NSObject+LKModel.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ F977B243321331B58666E9284634101A /* FMResultSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B89D386F780AC8FB5CEF4C7D015B0DF /* FMResultSet.h */; settings = {ATTRIBUTES = (Public, ); }; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 84F80CC25373993548DEECBE4A37689D /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 3528FA1DBE3E5C6AB799FC7BEA473755;
+ remoteInfo = LKDBHelper;
+ };
+ AD0B6C4B7F50123DDFF3584C74BE32A0 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 9F12FB4A63E20F601CFB2E64A65B57C1;
+ remoteInfo = FMDB;
+ };
+ C0B96BD7BF697EC2987D4CF7FC3679E1 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 9F12FB4A63E20F601CFB2E64A65B57C1;
+ remoteInfo = FMDB;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXFileReference section */
+ 096D0DA55BF7651EDDA19C5D0E9316AD /* LKDBHelper.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = LKDBHelper.xcconfig; sourceTree = ""; };
+ 0A4222AB40D3E7DF76F0A4BEC7A76C52 /* NSObject+LKModel.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSObject+LKModel.m"; path = "LKDBHelper/Helper/NSObject+LKModel.m"; sourceTree = ""; };
+ 10834806BD7B412BC24F347361FA2C8E /* Pods-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-acknowledgements.plist"; sourceTree = ""; };
+ 189AF3CE7D1B7E6CDB3CFC19E205EFAE /* FMDB.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = FMDB.xcconfig; sourceTree = ""; };
+ 272643F56613CA0D336AE3DBF19DC404 /* Pods-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-dummy.m"; sourceTree = ""; };
+ 2DA18E47FA8251446CA04F937D58CC3D /* LKDBHelper.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = LKDBHelper.m; path = LKDBHelper/Helper/LKDBHelper.m; sourceTree = ""; };
+ 32AA236946BD3FAF2EDBF8380E9946E1 /* LKDBHelper-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "LKDBHelper-prefix.pch"; sourceTree = ""; };
+ 32B4637969D4672AB662708E1B61828B /* FMDatabasePool.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = FMDatabasePool.h; path = src/fmdb/FMDatabasePool.h; sourceTree = ""; };
+ 37DB56D75062CC75FCB0966E1C6E8A8E /* Pods-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-acknowledgements.markdown"; sourceTree = ""; };
+ 3B89D386F780AC8FB5CEF4C7D015B0DF /* FMResultSet.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = FMResultSet.h; path = src/fmdb/FMResultSet.h; sourceTree = ""; };
+ 3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
+ 47CAE78BC5812E23FBC400D441F8BCB2 /* FMDB.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = FMDB.h; path = src/fmdb/FMDB.h; sourceTree = ""; };
+ 4E762F23EC34ED4A6FF3312D84E33A40 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.debug.xcconfig; sourceTree = ""; };
+ 4EA9DA2D741BC470E0085B62B62A8731 /* NSObject+LKDBHelper.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSObject+LKDBHelper.h"; path = "LKDBHelper/Helper/NSObject+LKDBHelper.h"; sourceTree = ""; };
+ 4F1C5CD724098DF351A8617144043B63 /* FMResultSet.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = FMResultSet.m; path = src/fmdb/FMResultSet.m; sourceTree = ""; };
+ 579F5ED8A0DAFD8C56FB430CB573C116 /* LKDBUtils.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = LKDBUtils.h; path = LKDBHelper/Helper/LKDBUtils.h; sourceTree = ""; };
+ 661C328D0A44FF0F3C8727F15BE23F44 /* NSObject+LKDBHelper.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "NSObject+LKDBHelper.m"; path = "LKDBHelper/Helper/NSObject+LKDBHelper.m"; sourceTree = ""; };
+ 6911BECA35E7518D864239B7E898EEF3 /* Pods-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-frameworks.sh"; sourceTree = ""; };
+ 6D054E379E6286CB236EA45DEE5E4DD4 /* FMDatabaseQueue.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = FMDatabaseQueue.h; path = src/fmdb/FMDatabaseQueue.h; sourceTree = ""; };
+ 6F3846A9AF7C473F2763CB0BF83414B2 /* LKDBHelper.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = LKDBHelper.h; path = LKDBHelper/Helper/LKDBHelper.h; sourceTree = ""; };
+ 7B107DC1588207AEB4CCE5B799B2290F /* FMDB-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "FMDB-dummy.m"; sourceTree = ""; };
+ 83504F76B9E9F30F01FF5598259399CD /* LKDBHelper-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "LKDBHelper-dummy.m"; sourceTree = ""; };
+ 842E99FC17A34EE232578016F97C9B43 /* NSObject+LKModel.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "NSObject+LKModel.h"; path = "LKDBHelper/Helper/NSObject+LKModel.h"; sourceTree = ""; };
+ 9293ABD725A0136D97B401C9D051372F /* FMDatabase.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = FMDatabase.m; path = src/fmdb/FMDatabase.m; sourceTree = ""; };
+ 98C98CDFB3F20F2925F6CD1F141BB14F /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Pods.release.xcconfig; sourceTree = ""; };
+ 99C9446B7DCE0B4CBF6063AC59AAFC11 /* FMDatabasePool.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = FMDatabasePool.m; path = src/fmdb/FMDatabasePool.m; sourceTree = ""; };
+ 9CC1536CDF92D4735DCB7E7181443AC7 /* libLKDBHelper.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libLKDBHelper.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ A1A36D34413696BE466E2CA0AFF194DA /* Pods-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-resources.sh"; sourceTree = ""; };
+ A632AAF02C79C77A8D32A8A1D0A95436 /* FMDatabaseQueue.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = FMDatabaseQueue.m; path = src/fmdb/FMDatabaseQueue.m; sourceTree = ""; };
+ AFCC279B2B823EB16199B9E263A89B26 /* LKDBUtils.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = LKDBUtils.m; path = LKDBHelper/Helper/LKDBUtils.m; sourceTree = ""; };
+ B2ACEC59A336186134ECD748A783725A /* LKDB+Mapping.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = "LKDB+Mapping.h"; path = "LKDBHelper/Helper/LKDB+Mapping.h"; sourceTree = ""; };
+ BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
+ BC3CD204A8C695091DDA08D099AD5302 /* FMDB-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "FMDB-prefix.pch"; sourceTree = ""; };
+ C81088D25095570D95881136B14A6D91 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ CF89E0700649464F25D39F4660E41E45 /* FMDatabaseAdditions.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = FMDatabaseAdditions.h; path = src/fmdb/FMDatabaseAdditions.h; sourceTree = ""; };
+ CFAE2E65D92A573B7E901BEED29AAAAB /* libFMDB.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFMDB.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ D28F07DC9FB3BDEC709C3B761C381C8F /* FMDatabase.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; name = FMDatabase.h; path = src/fmdb/FMDatabase.h; sourceTree = ""; };
+ D991A0D7A853849BD0F44613E61E1D0A /* LKDB+Mapping.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = "LKDB+Mapping.m"; path = "LKDBHelper/Helper/LKDB+Mapping.m"; sourceTree = ""; };
+ ED4E31DC0E75C1F49FB1EEBA4EC5F58D /* FMDatabaseAdditions.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; name = FMDatabaseAdditions.m; path = src/fmdb/FMDatabaseAdditions.m; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 71B4C990719C6DDE92D875F132F44D9F /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 266F0CD3A0A86BF17CF44201A39DAAB0 /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 84AF63084FFE4472EFC6131BD113B13D /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 587B76A3E381AF7C3EFFDF6754D39288 /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 8ECB7B859D751982F7EE04A17EC06D51 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 217CF9A8EB62F149658E7865882D1598 /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 037C0CA694176A3C0915F62C9D20B3E6 /* Targets Support Files */ = {
+ isa = PBXGroup;
+ children = (
+ B3D1D13E0C6553800746CB8FD61CF946 /* Pods */,
+ );
+ name = "Targets Support Files";
+ sourceTree = "";
+ };
+ 0D0124EC7EBD6E15064F54573F8B9B50 /* Support Files */ = {
+ isa = PBXGroup;
+ children = (
+ 189AF3CE7D1B7E6CDB3CFC19E205EFAE /* FMDB.xcconfig */,
+ 7B107DC1588207AEB4CCE5B799B2290F /* FMDB-dummy.m */,
+ BC3CD204A8C695091DDA08D099AD5302 /* FMDB-prefix.pch */,
+ );
+ name = "Support Files";
+ path = "../Target Support Files/FMDB";
+ sourceTree = "";
+ };
+ 10349CBBA829D9AA2DAAA394553917C0 /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 16F9757E7806FD29E195E98A4A727B28 /* FMDB */,
+ 4718F8A3D360F6291CD535D0B0EE2EA5 /* LKDBHelper */,
+ );
+ name = Pods;
+ sourceTree = "";
+ };
+ 13919718A5409C1D3A76E63321FD0FAA /* standard */ = {
+ isa = PBXGroup;
+ children = (
+ D28F07DC9FB3BDEC709C3B761C381C8F /* FMDatabase.h */,
+ 9293ABD725A0136D97B401C9D051372F /* FMDatabase.m */,
+ CF89E0700649464F25D39F4660E41E45 /* FMDatabaseAdditions.h */,
+ ED4E31DC0E75C1F49FB1EEBA4EC5F58D /* FMDatabaseAdditions.m */,
+ 32B4637969D4672AB662708E1B61828B /* FMDatabasePool.h */,
+ 99C9446B7DCE0B4CBF6063AC59AAFC11 /* FMDatabasePool.m */,
+ 6D054E379E6286CB236EA45DEE5E4DD4 /* FMDatabaseQueue.h */,
+ A632AAF02C79C77A8D32A8A1D0A95436 /* FMDatabaseQueue.m */,
+ 47CAE78BC5812E23FBC400D441F8BCB2 /* FMDB.h */,
+ 3B89D386F780AC8FB5CEF4C7D015B0DF /* FMResultSet.h */,
+ 4F1C5CD724098DF351A8617144043B63 /* FMResultSet.m */,
+ );
+ name = standard;
+ sourceTree = "";
+ };
+ 16F9757E7806FD29E195E98A4A727B28 /* FMDB */ = {
+ isa = PBXGroup;
+ children = (
+ 13919718A5409C1D3A76E63321FD0FAA /* standard */,
+ 0D0124EC7EBD6E15064F54573F8B9B50 /* Support Files */,
+ );
+ path = FMDB;
+ sourceTree = "";
+ };
+ 425901EE6279CD12BC952E92F484B37B /* Support Files */ = {
+ isa = PBXGroup;
+ children = (
+ 096D0DA55BF7651EDDA19C5D0E9316AD /* LKDBHelper.xcconfig */,
+ 83504F76B9E9F30F01FF5598259399CD /* LKDBHelper-dummy.m */,
+ 32AA236946BD3FAF2EDBF8380E9946E1 /* LKDBHelper-prefix.pch */,
+ );
+ name = "Support Files";
+ path = "../Target Support Files/LKDBHelper";
+ sourceTree = "";
+ };
+ 4718F8A3D360F6291CD535D0B0EE2EA5 /* LKDBHelper */ = {
+ isa = PBXGroup;
+ children = (
+ B2ACEC59A336186134ECD748A783725A /* LKDB+Mapping.h */,
+ D991A0D7A853849BD0F44613E61E1D0A /* LKDB+Mapping.m */,
+ 6F3846A9AF7C473F2763CB0BF83414B2 /* LKDBHelper.h */,
+ 2DA18E47FA8251446CA04F937D58CC3D /* LKDBHelper.m */,
+ 579F5ED8A0DAFD8C56FB430CB573C116 /* LKDBUtils.h */,
+ AFCC279B2B823EB16199B9E263A89B26 /* LKDBUtils.m */,
+ 4EA9DA2D741BC470E0085B62B62A8731 /* NSObject+LKDBHelper.h */,
+ 661C328D0A44FF0F3C8727F15BE23F44 /* NSObject+LKDBHelper.m */,
+ 842E99FC17A34EE232578016F97C9B43 /* NSObject+LKModel.h */,
+ 0A4222AB40D3E7DF76F0A4BEC7A76C52 /* NSObject+LKModel.m */,
+ 425901EE6279CD12BC952E92F484B37B /* Support Files */,
+ );
+ path = LKDBHelper;
+ sourceTree = "";
+ };
+ 7DB346D0F39D3F0E887471402A8071AB = {
+ isa = PBXGroup;
+ children = (
+ BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */,
+ BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */,
+ 10349CBBA829D9AA2DAAA394553917C0 /* Pods */,
+ F8B74780ED195B43D18388EDE5B84391 /* Products */,
+ 037C0CA694176A3C0915F62C9D20B3E6 /* Targets Support Files */,
+ );
+ sourceTree = "";
+ };
+ B3D1D13E0C6553800746CB8FD61CF946 /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 37DB56D75062CC75FCB0966E1C6E8A8E /* Pods-acknowledgements.markdown */,
+ 10834806BD7B412BC24F347361FA2C8E /* Pods-acknowledgements.plist */,
+ 272643F56613CA0D336AE3DBF19DC404 /* Pods-dummy.m */,
+ 6911BECA35E7518D864239B7E898EEF3 /* Pods-frameworks.sh */,
+ A1A36D34413696BE466E2CA0AFF194DA /* Pods-resources.sh */,
+ 4E762F23EC34ED4A6FF3312D84E33A40 /* Pods.debug.xcconfig */,
+ 98C98CDFB3F20F2925F6CD1F141BB14F /* Pods.release.xcconfig */,
+ );
+ name = Pods;
+ path = "Target Support Files/Pods";
+ sourceTree = "";
+ };
+ BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ BF6342C8B29F4CEEA088EFF7AB4DE362 /* iOS */,
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
+ BF6342C8B29F4CEEA088EFF7AB4DE362 /* iOS */ = {
+ isa = PBXGroup;
+ children = (
+ 3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */,
+ );
+ name = iOS;
+ sourceTree = "";
+ };
+ F8B74780ED195B43D18388EDE5B84391 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ CFAE2E65D92A573B7E901BEED29AAAAB /* libFMDB.a */,
+ 9CC1536CDF92D4735DCB7E7181443AC7 /* libLKDBHelper.a */,
+ C81088D25095570D95881136B14A6D91 /* libPods.a */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+ 8B2D82357BE4C2A10AB2CD4724B8E654 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D0D5FFE53407F16C9CD3D0ECF43ACE93 /* FMDatabase.h in Headers */,
+ B418C9BDCF8C6BAC2E3942F157BB6D4C /* FMDatabaseAdditions.h in Headers */,
+ 0F8A8E0D6FAEBF758E0B4D620335F094 /* FMDatabasePool.h in Headers */,
+ D0C5FF5485EAA2CDA03E9796B407697A /* FMDatabaseQueue.h in Headers */,
+ 313531CEDA0294311D87B4F4C3F073F4 /* FMDB.h in Headers */,
+ F977B243321331B58666E9284634101A /* FMResultSet.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 954586A4EDB8D23E0BC801F5A622B267 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 11B336E91CE118B99E33125F23E20BA9 /* LKDB+Mapping.h in Headers */,
+ C76FBC312FDF3897164382CFA7D47206 /* LKDBHelper.h in Headers */,
+ B2B08C521A8EF41B71F97B10EA026D12 /* LKDBUtils.h in Headers */,
+ 4C6AEE3AE764C0D9F09CFA0F58CA401D /* NSObject+LKDBHelper.h in Headers */,
+ F51DE617E72C6987AB8BBDFCA15EA414 /* NSObject+LKModel.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+ 3528FA1DBE3E5C6AB799FC7BEA473755 /* LKDBHelper */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 4FCF48C77EE0EDDA3A09BBBCDD185B90 /* Build configuration list for PBXNativeTarget "LKDBHelper" */;
+ buildPhases = (
+ C4D6597ADF8B8876C551144ED75E38C1 /* Sources */,
+ 71B4C990719C6DDE92D875F132F44D9F /* Frameworks */,
+ 954586A4EDB8D23E0BC801F5A622B267 /* Headers */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ AB90A6213A884169A37AC200621E65DE /* PBXTargetDependency */,
+ );
+ name = LKDBHelper;
+ productName = LKDBHelper;
+ productReference = 9CC1536CDF92D4735DCB7E7181443AC7 /* libLKDBHelper.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+ 9F12FB4A63E20F601CFB2E64A65B57C1 /* FMDB */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 3AC899FD215914230EB9D8B57AD910D0 /* Build configuration list for PBXNativeTarget "FMDB" */;
+ buildPhases = (
+ 050B66E154969A68944942A22BD9B314 /* Sources */,
+ 84AF63084FFE4472EFC6131BD113B13D /* Frameworks */,
+ 8B2D82357BE4C2A10AB2CD4724B8E654 /* Headers */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = FMDB;
+ productName = FMDB;
+ productReference = CFAE2E65D92A573B7E901BEED29AAAAB /* libFMDB.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+ BC1ADB8F702D9DCA556FA3403C79CA2F /* Pods */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 4BC97518F05FC32433C4F0D5D611E72B /* Build configuration list for PBXNativeTarget "Pods" */;
+ buildPhases = (
+ A69A0FA833CA6F0C7F727030A0E3E7B6 /* Sources */,
+ 8ECB7B859D751982F7EE04A17EC06D51 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ C12265D09D04813F149C3C3FAF14D917 /* PBXTargetDependency */,
+ 19A857E4371D9D0F681F9862F649EFD2 /* PBXTargetDependency */,
+ );
+ name = Pods;
+ productName = Pods;
+ productReference = C81088D25095570D95881136B14A6D91 /* libPods.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ D41D8CD98F00B204E9800998ECF8427E /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastSwiftUpdateCheck = 0700;
+ LastUpgradeCheck = 0700;
+ };
+ buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = 7DB346D0F39D3F0E887471402A8071AB;
+ productRefGroup = F8B74780ED195B43D18388EDE5B84391 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 9F12FB4A63E20F601CFB2E64A65B57C1 /* FMDB */,
+ 3528FA1DBE3E5C6AB799FC7BEA473755 /* LKDBHelper */,
+ BC1ADB8F702D9DCA556FA3403C79CA2F /* Pods */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 050B66E154969A68944942A22BD9B314 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ CA027706DD6805766F1F4EC548E72440 /* FMDatabase.m in Sources */,
+ A350C5704A1F233DAD830E081E00F8C1 /* FMDatabaseAdditions.m in Sources */,
+ 0EF8E9AA652DBE2745A7D5C8CD2E3BDE /* FMDatabasePool.m in Sources */,
+ 282081E035E7A843068E8BCC2E07C217 /* FMDatabaseQueue.m in Sources */,
+ 3D0F69C4CA35EB6A1F686BA88B19B4F6 /* FMDB-dummy.m in Sources */,
+ DEFA3504695E9DFDE1177DAB22884470 /* FMResultSet.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ A69A0FA833CA6F0C7F727030A0E3E7B6 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 4A7C771B81E0B36DFB89AB6AE0A6C8AE /* Pods-dummy.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ C4D6597ADF8B8876C551144ED75E38C1 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D55C7FDDC32FFC90257BC908F1D85026 /* LKDB+Mapping.m in Sources */,
+ 4D419D1E29614725D1515157C5262C78 /* LKDBHelper-dummy.m in Sources */,
+ 56D7A9D7CD648F77F08402F80EC1EC41 /* LKDBHelper.m in Sources */,
+ 0050321B606BB2AD14A3FA5C0BCB7DC8 /* LKDBUtils.m in Sources */,
+ 12B089D53EF77FC551CD25AD27B805FD /* NSObject+LKDBHelper.m in Sources */,
+ 1FA39854D4CEF957A35DABFC4EE56BFC /* NSObject+LKModel.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 19A857E4371D9D0F681F9862F649EFD2 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = LKDBHelper;
+ target = 3528FA1DBE3E5C6AB799FC7BEA473755 /* LKDBHelper */;
+ targetProxy = 84F80CC25373993548DEECBE4A37689D /* PBXContainerItemProxy */;
+ };
+ AB90A6213A884169A37AC200621E65DE /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = FMDB;
+ target = 9F12FB4A63E20F601CFB2E64A65B57C1 /* FMDB */;
+ targetProxy = AD0B6C4B7F50123DDFF3584C74BE32A0 /* PBXContainerItemProxy */;
+ };
+ C12265D09D04813F149C3C3FAF14D917 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = FMDB;
+ target = 9F12FB4A63E20F601CFB2E64A65B57C1 /* FMDB */;
+ targetProxy = C0B96BD7BF697EC2987D4CF7FC3679E1 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+ 052A17875CB827423D627183396CEB60 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = YES;
+ ENABLE_NS_ASSERTIONS = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_PREPROCESSOR_DEFINITIONS = "RELEASE=1";
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ STRIP_INSTALLED_PRODUCT = NO;
+ SYMROOT = "${SRCROOT}/../build";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ 4C332EBF6A53BEF5F790DC5AC176A04D /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 096D0DA55BF7651EDDA19C5D0E9316AD /* LKDBHelper.xcconfig */;
+ buildSettings = {
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_PREFIX_HEADER = "Target Support Files/LKDBHelper/LKDBHelper-prefix.pch";
+ IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ OTHER_LDFLAGS = "";
+ OTHER_LIBTOOLFLAGS = "";
+ PRIVATE_HEADERS_FOLDER_PATH = "";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ PUBLIC_HEADERS_FOLDER_PATH = "";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ 641F071BD177C0FD805ECAF1D202F7CB /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 189AF3CE7D1B7E6CDB3CFC19E205EFAE /* FMDB.xcconfig */;
+ buildSettings = {
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_PREFIX_HEADER = "Target Support Files/FMDB/FMDB-prefix.pch";
+ IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ OTHER_LDFLAGS = "";
+ OTHER_LIBTOOLFLAGS = "";
+ PRIVATE_HEADERS_FOLDER_PATH = "";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ PUBLIC_HEADERS_FOLDER_PATH = "";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+ 6725E0211ACC4A858DD168633084037A /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 4E762F23EC34ED4A6FF3312D84E33A40 /* Pods.debug.xcconfig */;
+ buildSettings = {
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ MACH_O_TYPE = staticlib;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ OTHER_LDFLAGS = "";
+ OTHER_LIBTOOLFLAGS = "";
+ PODS_ROOT = "$(SRCROOT)";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ 7A43CC24CE82729128B49A80D1A005E1 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 096D0DA55BF7651EDDA19C5D0E9316AD /* LKDBHelper.xcconfig */;
+ buildSettings = {
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_PREFIX_HEADER = "Target Support Files/LKDBHelper/LKDBHelper-prefix.pch";
+ IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ OTHER_LDFLAGS = "";
+ OTHER_LIBTOOLFLAGS = "";
+ PRIVATE_HEADERS_FOLDER_PATH = "";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ PUBLIC_HEADERS_FOLDER_PATH = "";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+ 8E22345807C46884D17DD8C2728A6201 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 189AF3CE7D1B7E6CDB3CFC19E205EFAE /* FMDB.xcconfig */;
+ buildSettings = {
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_PREFIX_HEADER = "Target Support Files/FMDB/FMDB-prefix.pch";
+ IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ OTHER_LDFLAGS = "";
+ OTHER_LIBTOOLFLAGS = "";
+ PRIVATE_HEADERS_FOLDER_PATH = "";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ PUBLIC_HEADERS_FOLDER_PATH = "";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ AF8A9F186275D7732AE94A10A74BDE96 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 98C98CDFB3F20F2925F6CD1F141BB14F /* Pods.release.xcconfig */;
+ buildSettings = {
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ MACH_O_TYPE = staticlib;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ OTHER_LDFLAGS = "";
+ OTHER_LIBTOOLFLAGS = "";
+ PODS_ROOT = "$(SRCROOT)";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+ B37F0F91F85060E28F1DAAB522DC7EC1 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 7.0;
+ ONLY_ACTIVE_ARCH = YES;
+ STRIP_INSTALLED_PRODUCT = NO;
+ SYMROOT = "${SRCROOT}/../build";
+ };
+ name = Debug;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ B37F0F91F85060E28F1DAAB522DC7EC1 /* Debug */,
+ 052A17875CB827423D627183396CEB60 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 3AC899FD215914230EB9D8B57AD910D0 /* Build configuration list for PBXNativeTarget "FMDB" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 8E22345807C46884D17DD8C2728A6201 /* Debug */,
+ 641F071BD177C0FD805ECAF1D202F7CB /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 4BC97518F05FC32433C4F0D5D611E72B /* Build configuration list for PBXNativeTarget "Pods" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 6725E0211ACC4A858DD168633084037A /* Debug */,
+ AF8A9F186275D7732AE94A10A74BDE96 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 4FCF48C77EE0EDDA3A09BBBCDD185B90 /* Build configuration list for PBXNativeTarget "LKDBHelper" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 4C332EBF6A53BEF5F790DC5AC176A04D /* Debug */,
+ 7A43CC24CE82729128B49A80D1A005E1 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
+}
diff --git a/ios/Pods/Target Support Files/FMDB/FMDB-dummy.m b/ios/Pods/Target Support Files/FMDB/FMDB-dummy.m
new file mode 100644
index 0000000..20ea8f1
--- /dev/null
+++ b/ios/Pods/Target Support Files/FMDB/FMDB-dummy.m
@@ -0,0 +1,5 @@
+#import
+@interface PodsDummy_FMDB : NSObject
+@end
+@implementation PodsDummy_FMDB
+@end
diff --git a/ios/Pods/Target Support Files/FMDB/FMDB-prefix.pch b/ios/Pods/Target Support Files/FMDB/FMDB-prefix.pch
new file mode 100644
index 0000000..aa992a4
--- /dev/null
+++ b/ios/Pods/Target Support Files/FMDB/FMDB-prefix.pch
@@ -0,0 +1,4 @@
+#ifdef __OBJC__
+#import
+#endif
+
diff --git a/ios/Pods/Target Support Files/FMDB/FMDB.xcconfig b/ios/Pods/Target Support Files/FMDB/FMDB.xcconfig
new file mode 100644
index 0000000..aa3f955
--- /dev/null
+++ b/ios/Pods/Target Support Files/FMDB/FMDB.xcconfig
@@ -0,0 +1,5 @@
+GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
+HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/FMDB" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" "${PODS_ROOT}/Headers/Public/LKDBHelper"
+OTHER_LDFLAGS = -l"sqlite3"
+PODS_ROOT = ${SRCROOT}
+SKIP_INSTALL = YES
\ No newline at end of file
diff --git a/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper-dummy.m b/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper-dummy.m
new file mode 100644
index 0000000..89e4b0c
--- /dev/null
+++ b/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper-dummy.m
@@ -0,0 +1,5 @@
+#import
+@interface PodsDummy_LKDBHelper : NSObject
+@end
+@implementation PodsDummy_LKDBHelper
+@end
diff --git a/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper-prefix.pch b/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper-prefix.pch
new file mode 100644
index 0000000..aa992a4
--- /dev/null
+++ b/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper-prefix.pch
@@ -0,0 +1,4 @@
+#ifdef __OBJC__
+#import
+#endif
+
diff --git a/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper.xcconfig b/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper.xcconfig
new file mode 100644
index 0000000..8f79e8f
--- /dev/null
+++ b/ios/Pods/Target Support Files/LKDBHelper/LKDBHelper.xcconfig
@@ -0,0 +1,4 @@
+GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
+HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/LKDBHelper" "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" "${PODS_ROOT}/Headers/Public/LKDBHelper"
+PODS_ROOT = ${SRCROOT}
+SKIP_INSTALL = YES
\ No newline at end of file
diff --git a/ios/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown b/ios/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown
new file mode 100644
index 0000000..c4c4ef0
--- /dev/null
+++ b/ios/Pods/Target Support Files/Pods/Pods-acknowledgements.markdown
@@ -0,0 +1,56 @@
+# Acknowledgements
+This application makes use of the following third party libraries:
+
+## FMDB
+
+If you are using FMDB in your project, I'd love to hear about it. Let Gus know
+by sending an email to gus@flyingmeat.com.
+
+And if you happen to come across either Gus Mueller or Rob Ryan in a bar, you
+might consider purchasing a drink of their choosing if FMDB has been useful to
+you.
+
+Finally, and shortly, this is the MIT License.
+
+Copyright (c) 2008-2014 Flying Meat Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+## LKDBHelper
+
+Copyright (c) 2012 Jianghuai Li (https://github.com/li6185377)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+Generated by CocoaPods - http://cocoapods.org
diff --git a/ios/Pods/Target Support Files/Pods/Pods-acknowledgements.plist b/ios/Pods/Target Support Files/Pods/Pods-acknowledgements.plist
new file mode 100644
index 0000000..74ab389
--- /dev/null
+++ b/ios/Pods/Target Support Files/Pods/Pods-acknowledgements.plist
@@ -0,0 +1,90 @@
+
+
+
+
+ PreferenceSpecifiers
+
+
+ FooterText
+ This application makes use of the following third party libraries:
+ Title
+ Acknowledgements
+ Type
+ PSGroupSpecifier
+
+
+ FooterText
+ If you are using FMDB in your project, I'd love to hear about it. Let Gus know
+by sending an email to gus@flyingmeat.com.
+
+And if you happen to come across either Gus Mueller or Rob Ryan in a bar, you
+might consider purchasing a drink of their choosing if FMDB has been useful to
+you.
+
+Finally, and shortly, this is the MIT License.
+
+Copyright (c) 2008-2014 Flying Meat Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+ Title
+ FMDB
+ Type
+ PSGroupSpecifier
+
+
+ FooterText
+ Copyright (c) 2012 Jianghuai Li (https://github.com/li6185377)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+ Title
+ LKDBHelper
+ Type
+ PSGroupSpecifier
+
+
+ FooterText
+ Generated by CocoaPods - http://cocoapods.org
+ Title
+
+ Type
+ PSGroupSpecifier
+
+
+ StringsTable
+ Acknowledgements
+ Title
+ Acknowledgements
+
+
diff --git a/ios/Pods/Target Support Files/Pods/Pods-dummy.m b/ios/Pods/Target Support Files/Pods/Pods-dummy.m
new file mode 100644
index 0000000..ade64bd
--- /dev/null
+++ b/ios/Pods/Target Support Files/Pods/Pods-dummy.m
@@ -0,0 +1,5 @@
+#import
+@interface PodsDummy_Pods : NSObject
+@end
+@implementation PodsDummy_Pods
+@end
diff --git a/ios/Pods/Target Support Files/Pods/Pods-frameworks.sh b/ios/Pods/Target Support Files/Pods/Pods-frameworks.sh
new file mode 100755
index 0000000..6f76344
--- /dev/null
+++ b/ios/Pods/Target Support Files/Pods/Pods-frameworks.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+set -e
+
+echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
+mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
+
+SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
+
+install_framework()
+{
+ if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
+ local source="${BUILT_PRODUCTS_DIR}/$1"
+ elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
+ local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
+ elif [ -r "$1" ]; then
+ local source="$1"
+ fi
+
+ local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
+
+ if [ -L "${source}" ]; then
+ echo "Symlinked..."
+ source="$(readlink "${source}")"
+ fi
+
+ # use filter instead of exclude so missing patterns dont' throw errors
+ echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
+ rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
+
+ local basename
+ basename="$(basename -s .framework "$1")"
+ binary="${destination}/${basename}.framework/${basename}"
+ if ! [ -r "$binary" ]; then
+ binary="${destination}/${basename}"
+ fi
+
+ # Strip invalid architectures so "fat" simulator / device frameworks work on device
+ if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
+ strip_invalid_archs "$binary"
+ fi
+
+ # Resign the code if required by the build settings to avoid unstable apps
+ code_sign_if_enabled "${destination}/$(basename "$1")"
+
+ # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
+ if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
+ local swift_runtime_libs
+ swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
+ for lib in $swift_runtime_libs; do
+ echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
+ rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
+ code_sign_if_enabled "${destination}/${lib}"
+ done
+ fi
+}
+
+# Signs a framework with the provided identity
+code_sign_if_enabled() {
+ if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
+ # Use the current code_sign_identitiy
+ echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
+ echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\""
+ /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1"
+ fi
+}
+
+# Strip invalid architectures
+strip_invalid_archs() {
+ binary="$1"
+ # Get architectures for current file
+ archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
+ stripped=""
+ for arch in $archs; do
+ if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
+ # Strip non-valid architectures in-place
+ lipo -remove "$arch" -output "$binary" "$binary" || exit 1
+ stripped="$stripped $arch"
+ fi
+ done
+ if [[ "$stripped" ]]; then
+ echo "Stripped $binary of architectures:$stripped"
+ fi
+}
+
diff --git a/ios/Pods/Target Support Files/Pods/Pods-resources.sh b/ios/Pods/Target Support Files/Pods/Pods-resources.sh
new file mode 100755
index 0000000..16774fb
--- /dev/null
+++ b/ios/Pods/Target Support Files/Pods/Pods-resources.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+set -e
+
+mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
+
+RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
+> "$RESOURCES_TO_COPY"
+
+XCASSET_FILES=()
+
+realpath() {
+ DIRECTORY="$(cd "${1%/*}" && pwd)"
+ FILENAME="${1##*/}"
+ echo "$DIRECTORY/$FILENAME"
+}
+
+install_resource()
+{
+ case $1 in
+ *.storyboard)
+ echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
+ ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
+ ;;
+ *.xib)
+ echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
+ ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
+ ;;
+ *.framework)
+ echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
+ mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
+ echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
+ rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
+ ;;
+ *.xcdatamodel)
+ echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
+ xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
+ ;;
+ *.xcdatamodeld)
+ echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
+ xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
+ ;;
+ *.xcmappingmodel)
+ echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\""
+ xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm"
+ ;;
+ *.xcassets)
+ ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1")
+ XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
+ ;;
+ /*)
+ echo "$1"
+ echo "$1" >> "$RESOURCES_TO_COPY"
+ ;;
+ *)
+ echo "${PODS_ROOT}/$1"
+ echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
+ ;;
+ esac
+}
+
+mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
+rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
+if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
+ mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
+ rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
+fi
+rm -f "$RESOURCES_TO_COPY"
+
+if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
+then
+ case "${TARGETED_DEVICE_FAMILY}" in
+ 1,2)
+ TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
+ ;;
+ 1)
+ TARGET_DEVICE_ARGS="--target-device iphone"
+ ;;
+ 2)
+ TARGET_DEVICE_ARGS="--target-device ipad"
+ ;;
+ *)
+ TARGET_DEVICE_ARGS="--target-device mac"
+ ;;
+ esac
+
+ # Find all other xcassets (this unfortunately includes those of path pods and other targets).
+ OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
+ while read line; do
+ if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
+ XCASSET_FILES+=("$line")
+ fi
+ done <<<"$OTHER_XCASSETS"
+
+ printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
+fi
diff --git a/ios/Pods/Target Support Files/Pods/Pods.debug.xcconfig b/ios/Pods/Target Support Files/Pods/Pods.debug.xcconfig
new file mode 100644
index 0000000..44b84c7
--- /dev/null
+++ b/ios/Pods/Target Support Files/Pods/Pods.debug.xcconfig
@@ -0,0 +1,5 @@
+GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
+HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" "${PODS_ROOT}/Headers/Public/LKDBHelper"
+OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/FMDB" -isystem "${PODS_ROOT}/Headers/Public/LKDBHelper"
+OTHER_LDFLAGS = $(inherited) -ObjC -l"FMDB" -l"LKDBHelper" -l"sqlite3"
+PODS_ROOT = ${SRCROOT}/Pods
\ No newline at end of file
diff --git a/ios/Pods/Target Support Files/Pods/Pods.release.xcconfig b/ios/Pods/Target Support Files/Pods/Pods.release.xcconfig
new file mode 100644
index 0000000..44b84c7
--- /dev/null
+++ b/ios/Pods/Target Support Files/Pods/Pods.release.xcconfig
@@ -0,0 +1,5 @@
+GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
+HEADER_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Headers/Public" "${PODS_ROOT}/Headers/Public/FMDB" "${PODS_ROOT}/Headers/Public/LKDBHelper"
+OTHER_CFLAGS = $(inherited) -isystem "${PODS_ROOT}/Headers/Public" -isystem "${PODS_ROOT}/Headers/Public/FMDB" -isystem "${PODS_ROOT}/Headers/Public/LKDBHelper"
+OTHER_LDFLAGS = $(inherited) -ObjC -l"FMDB" -l"LKDBHelper" -l"sqlite3"
+PODS_ROOT = ${SRCROOT}/Pods
\ No newline at end of file