Inherits from NSObject
Declared in FMDatabasePool.h

Overview

Pool of FMDatabase objects.

See also

Warning: Before using FMDatabasePool, please consider using FMDatabaseQueue 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.

Tasks

Other Methods

Initialization

Keeping track of checked in/out databases

Perform database operations in pool

Properties

delegate

@property (atomic, assign) id delegate
Discussion

Delegate object

Declared In

FMDatabasePool.h

maximumNumberOfDatabasesToCreate

@property (atomic, assign) NSUInteger maximumNumberOfDatabasesToCreate
Discussion

Maximum number of databases to create

Declared In

FMDatabasePool.h

openFlags

@property (atomic, readonly) int openFlags
Discussion

Open flags

Declared In

FMDatabasePool.h

path

@property (atomic, retain) NSString *path
Discussion

Database path

Declared In

FMDatabasePool.h

Class Methods

databasePoolWithPath:

+ (instancetype)databasePoolWithPath:(NSString *)aPath
Discussion

Create pool using path.

Parameters

aPath

The file path of the database.

Return Value

The FMDatabasePool object. nil on error.

Declared In

FMDatabasePool.h

databasePoolWithPath:flags:

+ (instancetype)databasePoolWithPath:(NSString *)aPath flags:(int)openFlags
Discussion

Create pool using path and specified flags

Parameters

aPath

The file path of the database.

openFlags

Flags passed to the openWithFlags method of the database

Return Value

The FMDatabasePool object. nil on error.

Declared In

FMDatabasePool.h

Instance Methods

countOfCheckedInDatabases

- (NSUInteger)countOfCheckedInDatabases
Discussion

Number of checked-in databases in pool

Return Value

Number of databases

Declared In

FMDatabasePool.h

countOfCheckedOutDatabases

- (NSUInteger)countOfCheckedOutDatabases
Discussion

Number of checked-out databases in pool

Return Value

Number of databases

Declared In

FMDatabasePool.h

countOfOpenDatabases

- (NSUInteger)countOfOpenDatabases
Discussion

Total number of databases in pool

Return Value

Number of databases

Declared In

FMDatabasePool.h

inDatabase:

- (void)inDatabase:(void ( ^ ) ( FMDatabase *db ))block
Discussion

Synchronously perform database operations in pool.

Parameters

block

The code to be run on the FMDatabasePool pool.

Declared In

FMDatabasePool.h

inDeferredTransaction:

- (void)inDeferredTransaction:(void ( ^ ) ( FMDatabase *db , BOOL *rollback ))block
Discussion

Synchronously perform database operations in pool using deferred transaction.

Parameters

block

The code to be run on the FMDatabasePool pool.

Declared In

FMDatabasePool.h

inSavePoint:

- (NSError *)inSavePoint:(void ( ^ ) ( FMDatabase *db , BOOL *rollback ))block
Discussion

Synchronously perform database operations in pool using save point.

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.

Parameters

block

The code to be run on the FMDatabasePool pool.

Return Value

NSError object if error; nil if successful.

Declared In

FMDatabasePool.h

inTransaction:

- (void)inTransaction:(void ( ^ ) ( FMDatabase *db , BOOL *rollback ))block
Discussion

Synchronously perform database operations in pool using transaction.

Parameters

block

The code to be run on the FMDatabasePool pool.

Declared In

FMDatabasePool.h

initWithPath:

- (instancetype)initWithPath:(NSString *)aPath
Discussion

Create pool using path.

Parameters

aPath

The file path of the database.

Return Value

The FMDatabasePool object. nil on error.

Declared In

FMDatabasePool.h

initWithPath:flags:

- (instancetype)initWithPath:(NSString *)aPath flags:(int)openFlags
Discussion

Create pool using path and specified flags.

Parameters

aPath

The file path of the database.

openFlags

Flags passed to the openWithFlags method of the database

Return Value

The FMDatabasePool object. nil on error.

Declared In

FMDatabasePool.h

releaseAllDatabases

- (void)releaseAllDatabases
Discussion

Release all databases in pool

Declared In

FMDatabasePool.h