n DataModel.swift. Now I get an error that says 'stringByAppendingPathComponent' is unavailable use URLByAppendingPathComponent on NSURL instead
but that's not even an option. What do we do to fix this?








class ViewController: UIViewController {

@IBOutlet weak var name: UITextField!
@IBOutlet weak var address: UITextField!
@IBOutlet weak var phone: UITextField!
@IBOutlet weak var status: UILabel!
var databasePath = NSString()





override func viewDidLoad() {
super.viewDidLoad()


let filemgr = NSFileManager.defaultManager()
let dirPaths =
NSSearchPathForDirectoriesInDomains(.DocumentDirectory,
.UserDomainMask, true)
let docsDir = dirPaths[0]

//let docsDir = dirPaths[0]

var databasePath = docsDir.stringByAppendingPathComponent(
"contacts.db")

if !filemgr.fileExistsAtPath(databasePath as String) {

let contactDB = FMDatabase(path: databasePath as String)

if contactDB == nil {
print("Error: \(contactDB.lastErrorMessage())")
}

if contactDB.open() {
let sql_stmt = "CREATE TABLE IF NOT EXISTS CONTACTS (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, ADDRESS TEXT, PHONE TEXT)"
if !contactDB.executeStatements(sql_stmt) {
print("Error: \(contactDB.lastErrorMessage())")
}
contactDB.close()
} else {
print("Error: \(contactDB.lastErrorMessage())")
}
}