Skip to content

Instantly share code, notes, and snippets.

@identity2
Created June 8, 2019 05:11
Show Gist options
  • Save identity2/d6fb7d59a26422844936b33634da3f33 to your computer and use it in GitHub Desktop.
Save identity2/d6fb7d59a26422844936b33634da3f33 to your computer and use it in GitHub Desktop.
Database Accessor 2
class DatabaseAccessor {
static let sharedInstance = DatabaseAccessor()
private init() {}
// The instance of the SQLite database
private var mainDB: FMDatabase?
public func initializeDatabase() {
let databasePath = (dirPath as NSString).appendingPathComponent("database.sqlite") as NSString
// Assign the instanced database.
mainDB = FMDatabase(path: databasePath as String)
}
public func closeDatabase() {
mainDB?.close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment