samedi 9 janvier 2016

Why do I get Unable to Open Database file?

I am a beginner in iOS development and I want to develop a database in my application. However, When I try to create the database it says unable to open database file.

enter image description here

For clarification (http://ift.tt/1JMpjez)

enter image description here

My code for the db development is as follow

static func DB(){

        do {
            let db = try Connection("db.sqlite3")
            let users = Table("users")
            let id = Expression<Int64>("id")
            let name = Expression<String?>("name")
            let email = Expression<String>("email")

            try db.run(users.create { t in
                t.column(id, primaryKey: true)
                t.column(name)
                t.column(email, unique: true)
                })

        } catch {
            print("Dim background error")
        }
}

I trigger this method from app delegate file

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.

        AppCommon.DB()

        return true
    }

How to fix this issue? Please help me out, I really need your help..!

Aucun commentaire:

Enregistrer un commentaire