Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ccgus/fmdb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Islamgulov <timislamgulov@yahoo.com>2013-12-18 21:01:32 +0400
committerTimur Islamgulov <timislamgulov@yahoo.com>2013-12-18 21:01:32 +0400
commit3f8cee50c46a3c2b3deb4323d10859c7c9f84595 (patch)
tree9d3320cba702cfc73f37faed1c536af869b8e25e
parent3c6d3ca6e167490f5f2417ea9ae14a9c43529abd (diff)
Fix for issue #211: Add 'databasePool:didAddDatabase:' method to FMDatabasePoolDelegate protocol
-rw-r--r--src/FMDatabasePool.h6
-rw-r--r--src/FMDatabasePool.m5
2 files changed, 11 insertions, 0 deletions
diff --git a/src/FMDatabasePool.h b/src/FMDatabasePool.h
index 3e1d53b..daf69b7 100644
--- a/src/FMDatabasePool.h
+++ b/src/FMDatabasePool.h
@@ -161,7 +161,13 @@
@interface NSObject (FMDatabasePoolDelegate)
+/** Asks the delegate whether database should be added to the pool. */
+
- (BOOL)databasePool:(FMDatabasePool*)pool shouldAddDatabaseToPool:(FMDatabase*)database;
+/** Tells the delegate that database was added to the pool. */
+
+- (void)databasePool:(FMDatabasePool*)pool didAddDatabase:(FMDatabase*)database;
+
@end
diff --git a/src/FMDatabasePool.m b/src/FMDatabasePool.m
index ccf4628..f515618 100644
--- a/src/FMDatabasePool.m
+++ b/src/FMDatabasePool.m
@@ -100,6 +100,7 @@
- (FMDatabase*)db {
__block FMDatabase *db;
+ __block BOOL shouldNotifyDelegate = NO;
[self executeLocked:^() {
db = [_databaseInPool lastObject];
@@ -120,6 +121,7 @@
}
db = [FMDatabase databaseWithPath:_path];
+ shouldNotifyDelegate = YES;
}
//This ensures that the db is opened before returning
@@ -136,6 +138,9 @@
//It should not get added in the pool twice if lastObject was found
if (![_databaseOutPool containsObject:db]) {
[_databaseOutPool addObject:db];
+
+ if ([_delegate respondsToSelector:@selector(databasePool:didAddDatabase:)] && shouldNotifyDelegate)
+ [_delegate databasePool:self didAddDatabase:db];
}
}
}