lundi 31 août 2015

How to save in app main directory sqlite file in swift?

I have this function:

 func takeDatabase() -> FMDatabase {
    let documentsFolder = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! String
    let path = documentsFolder.stringByAppendingPathComponent("test.sqlite")

    let database = FMDatabase(path: path)
    // println(path)
    if !database.open() {
        println("Unable to open database")

    }

    return database
}

I want to change the path, to be in main directory of my app. How can I do this? I try a lot, but with no results.

Thanks

Aucun commentaire:

Enregistrer un commentaire