瀏覽代碼

Merge pull request #213 from 5at5ish/master

Fix for issue #203: Add 'databaseClass' class method for FMDatabaseQueue.
August "Gus" Mueller 12 年之前
父節點
當前提交
4250e03227
共有 2 個文件被更改,包括 14 次插入1 次删除
  1. 9 0
      src/FMDatabaseQueue.h
  2. 5 1
      src/FMDatabaseQueue.m

+ 9 - 0
src/FMDatabaseQueue.h

@@ -112,6 +112,15 @@
 
 - (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags;
 
+/** 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;

+ 5 - 1
src/FMDatabaseQueue.m

@@ -40,6 +40,10 @@ + (instancetype)databaseQueueWithPath:(NSString*)aPath flags:(int)openFlags {
     return q;
 }
 
++ (Class)databaseClass
+{
+    return [FMDatabase class];
+}
 
 - (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags {
     
@@ -47,7 +51,7 @@ - (instancetype)initWithPath:(NSString*)aPath flags:(int)openFlags {
     
     if (self != nil) {
         
-        _db = [FMDatabase databaseWithPath:aPath];
+        _db = [[[self class] databaseClass] databaseWithPath:aPath];
         FMDBRetain(_db);
         
 #if SQLITE_VERSION_NUMBER >= 3005000