I have a singleton class:
class Database { static let instance:Database = Database() private var db: Connection? private init(){ do { db = try Connection("\(path)/SalesPresenterDatabase.sqlite3") }catch{print(error)} } }
Now I access this class using Database.instance.xxxxxx to execute the function inside the class. However, when I access an instance from another thread, it throws fancy results, as if it were trying to create another instance. Should I refer to an instance in the same thread?
To clarify that fancy results show database I / O errors due to two instances trying to access db right away
Refresh
refer to this question for more information on the database code: Using transactions to insert are errors loading Sqlite.swift
source share