/SQLite_SingleManagerClass

SQLite SingleTonManagerClass and use of FMDB

Primary LanguageObjective-C

SQLite_SingleManagerClass

SQLite SingleManagerClass and use of FMDB

  • SingleTonManager class
  • Swift language
  • Use of FMDB
  • Create database
  • Insert, update, delete & select operations

Implementation step

  • Create your .db file
  • Add freamework libsqlite3.tbd
  • Drag and drop LocalDatabase.swift file into your project

Method to create database

LocalDatabase.sharedInstance.methodToCreateDatabase()

Method to insert, update and delete data

LocalDatabase.sharedInstance.methodToInsertUpdateDeleteData("INSERT INTO CONTACTS_TABLE (name, address, phone) VALUES ('Satyam Mall', 'Brainvire', 0085)", completion: { (completed) in
    if completed
    {
        print("Data updated successfully")
    }
    else
    {
        print("Fail while data updation")
    }
})

Method to select data

LocalDatabase.sharedInstance.methodToSelectData("SELECT * FROM CONTACTS_TABLE", completion: { (dataReturned) in
    print(dataReturned)
})

simulator screen shot 18-jan-2017 1 02 22 pm