Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
创建SQLite数据库导入fmdatabase.h文件_Sqlite - Fatal编程技术网

创建SQLite数据库导入fmdatabase.h文件

创建SQLite数据库导入fmdatabase.h文件,sqlite,Sqlite,我正在我的swift项目中添加文件。。。 根据,我必须#将“FMDB.h”导入我的桥接头 我有桥接头文件名:FMDB.h 然后我是否用其他名称创建了新的桥接头并将其添加到我的fmdb文件夹中 我还实现了代码 let path = NSBundle.mainBundle().pathForResource("test", ofType:"sqlite") let database = FMDatabase(path: path) if !database.open() { printl

我正在我的swift项目中添加文件。。。
根据,我必须
#将“FMDB.h”
导入我的桥接头
我有桥接头文件名:FMDB.h
然后我是否用其他名称创建了新的桥接头并将其添加到我的fmdb文件夹中

我还实现了代码

let path = NSBundle.mainBundle().pathForResource("test", ofType:"sqlite")

let database = FMDatabase(path: path)

if !database.open() {
    println("Unable to open database")
    return
}
但它不起作用


请帮助我

您可以添加这样的代码

let filemgr = NSFileManager.defaultManager()
let dirPaths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let docsDir : String = dirPaths[0] as! String
databasePath = docsDir.stringByAppendingPathComponent("db.sqlite")
if filemgr.fileExistsAtPath(databasePath as String) {
   let contactDB = FMDatabase(path: databasePath as String)
   if contactDB.open() {
   //write your code
   }
}

这是我的工作

帕拉克也有同样的问题