FMDatabasePool Class Reference

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.

Other Methods

  path

Database path

@property (atomic, copy, nullable) NSString *path

Discussion

Database path

Declared In

FMDatabasePool.h

  delegate

Delegate object

@property (atomic, assign, nullable) id delegate

Discussion

Delegate object

Declared In

FMDatabasePool.h

  maximumNumberOfDatabasesToCreate

Maximum number of databases to create

@property (atomic, assign) NSUInteger maximumNumberOfDatabasesToCreate

Discussion

Maximum number of databases to create

Declared In

FMDatabasePool.h

  openFlags

Open flags

@property (atomic, readonly) int openFlags

Discussion

Open flags

Declared In

FMDatabasePool.h

  vfsName

Custom virtual file system name

@property (atomic, copy, nullable) NSString *vfsName

Discussion

Custom virtual file system name

Declared In

FMDatabasePool.h

Initialization

+ databasePoolWithPath:

Create pool using path.

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

Parameters

aPath

The file path of the database.

Return Value

The FMDatabasePool object. nil on error.

Discussion

Create pool using path.

Declared In

FMDatabasePool.h

+ databasePoolWithURL:

Create pool using file URL.

+ (instancetype)databasePoolWithURL:(NSURL *_Nullable)url

Parameters

url

The file NSURL of the database.

Return Value

The FMDatabasePool object. nil on error.

Discussion

Create pool using file URL.

Declared In

FMDatabasePool.h

+ databasePoolWithPath:flags:

Create pool using path and specified flags

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

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.

Discussion

Create pool using path and specified flags

Declared In

FMDatabasePool.h

+ databasePoolWithURL:flags:

Create pool using file URL and specified flags

+ (instancetype)databasePoolWithURL:(NSURL *_Nullable)url flags:(int)openFlags

Parameters

url

The file NSURL of the database.

openFlags

Flags passed to the openWithFlags method of the database.

Return Value

The FMDatabasePool object. nil on error.

Discussion

Create pool using file URL and specified flags

Declared In

FMDatabasePool.h

– initWithPath:

Create pool using path.

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

Parameters

aPath

The file path of the database.

Return Value

The FMDatabasePool object. nil on error.

Discussion

Create pool using path.

Declared In

FMDatabasePool.h

– initWithURL:

Create pool using file URL.

- (instancetype)initWithURL:(NSURL *_Nullable)url

Parameters

url

The file `NSURL of the database.

Return Value

The FMDatabasePool object. nil on error.

Discussion

Create pool using file URL.

Declared In

FMDatabasePool.h

– initWithPath:flags:

Create pool using path and specified flags.

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

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.

Discussion

Create pool using path and specified flags.

Declared In

FMDatabasePool.h

– initWithURL:flags:

Create pool using file URL and specified flags.

- (instancetype)initWithURL:(NSURL *_Nullable)url flags:(int)openFlags

Parameters

url

The file NSURL of the database.

openFlags

Flags passed to the openWithFlags method of the database

Return Value

The FMDatabasePool object. nil on error.

Discussion

Create pool using file URL and specified flags.

Declared In

FMDatabasePool.h

– initWithPath:flags:vfs:

Create pool using path and specified flags.

- (instancetype)initWithPath:(NSString *_Nullable)aPath flags:(int)openFlags vfs:(NSString *_Nullable)vfsName

Parameters

aPath

The file path of the database.

openFlags

Flags passed to the openWithFlags method of the database

vfsName

The name of a custom virtual file system

Return Value

The FMDatabasePool object. nil on error.

Discussion

Create pool using path and specified flags.

Declared In

FMDatabasePool.h

– initWithURL:flags:vfs:

Create pool using file URL and specified flags.

- (instancetype)initWithURL:(NSURL *_Nullable)url flags:(int)openFlags vfs:(NSString *_Nullable)vfsName

Parameters

url

The file NSURL of the database.

openFlags

Flags passed to the openWithFlags method of the database

vfsName

The name of a custom virtual file system

Return Value

The FMDatabasePool object. nil on error.

Discussion

Create pool using file URL and specified flags.

Declared In

FMDatabasePool.h

+ databaseClass

Returns the Class of ‘FMDatabase’ subclass, that will be used to instantiate database object.

+ (Class)databaseClass

Return Value

The Class of ‘FMDatabase’ subclass, that will be used to instantiate database object.

Discussion

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.

Declared In

FMDatabasePool.h

Keeping track of checked in/out databases

  countOfCheckedInDatabases

Number of checked-in databases in pool

@property (nonatomic, readonly) NSUInteger countOfCheckedInDatabases

Discussion

Number of checked-in databases in pool

Declared In

FMDatabasePool.h

  countOfCheckedOutDatabases

Number of checked-out databases in pool

@property (nonatomic, readonly) NSUInteger countOfCheckedOutDatabases

Discussion

Number of checked-out databases in pool

Declared In

FMDatabasePool.h

  countOfOpenDatabases

Total number of databases in pool

@property (nonatomic, readonly) NSUInteger countOfOpenDatabases

Discussion

Total number of databases in pool

Declared In

FMDatabasePool.h

– releaseAllDatabases

Release all databases in pool

- (void)releaseAllDatabases

Discussion

Release all databases in pool

Declared In

FMDatabasePool.h

Perform database operations in pool

– inDatabase:

Synchronously perform database operations in pool.

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

Parameters

block

The code to be run on the FMDatabasePool pool.

Discussion

Synchronously perform database operations in pool.

Declared In

FMDatabasePool.h

– inTransaction:

Synchronously perform database operations in pool using transaction.

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

Parameters

block

The code to be run on the FMDatabasePool pool.

Discussion

Synchronously perform database operations in pool using transaction.

Declared In

FMDatabasePool.h

– inDeferredTransaction:

Synchronously perform database operations in pool using deferred transaction.

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

Parameters

block

The code to be run on the FMDatabasePool pool.

Discussion

Synchronously perform database operations in pool using deferred transaction.

Declared In

FMDatabasePool.h

– inSavePoint:

Synchronously perform database operations in pool using save point.

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

Parameters

block

The code to be run on the FMDatabasePool pool.

Return Value

NSError object if error; nil if successful.

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.

Declared In

FMDatabasePool.h