I'm writing my first swift universal app. I have used Sqlite3 in objective-c apps before so I would like to think i have a fairly decent knowledge of it. I'm using Sqlite3 to store data that is downloaded from a server when the app first loads. The problem i'm having is that when I run the app on the IOS simulator it works just fine, however when I run it on an actual device it doesn't seem to be creating the database file.
I have the following code
func dataFilePath() -> String
{
let documentDirectory = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
return documentDirectory
}
func dataFile() -> String
{
return "App.sqlite3"
}
func InitialiseDatabase()
{
var databaseName = dataFilePath()
databaseName += dataFile()
var database:COpaquePointer = nil
var result = sqlite3_open(databaseName, &database)
if result != SQLITE_OK {
println(sqlite3_errmsg(database));
sqlite3_close(database)
return
}
.......... more code here
When this runs it is not returning SQLITE_OK on the actual device. I'm wondering if it's some sort of permissions issue? sqlite_3_errmsg just returns some code which doesn't bring up any results on google so that hasn't helped.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire