0

I'm rewriting an App purely in Swift. Just starting on the Database for which I use FMDB. I took some same code out of the "iOS8 App Development Essentials". When I compile the line:

let locationsDB = FMDatabase(path: databasePath as String)

It gives me a Use of Unresolved Identifier "FMDatabase" error. This part of the code reads:

let filemgr = NSFileManager.defaultManager()
        let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
        let docsDir = dirPaths[0] as! String
        databasePath = docsDir.stringByAppendingPathComponent("locations.db")

        if !filemgr.fileExistsAtPath(databasePath as String) {
            let locationsDB = FMDatabase(path: databasePath as String)

            etc...

Any ideas?

Edward Hasted
  • 3,201
  • 8
  • 30
  • 48

1 Answers1

0

I found a solution by adding :

var databasePath:String!

on the top of the ViewController, because the error was saying that the databasePath was not declared.

As a consequence I declared it as a variable of type string that can be null (!). In my case, it worked just fine.

Alexander
  • 2,925
  • 3
  • 33
  • 36
  • simply because the error was saying the databasePath was not declared. As a consequence I declared it as a variable of type string that can be null (!). In my case, it worked just fine. Now I am far from being an expert and maybe my axplainations are not comprehensive... – Anne B Perrault Jun 23 '15 at 14:58