【发布时间】:2016-01-29 04:49:34
【问题描述】:
我收到此错误。我找到了类似的代码。我尝试修复但无法修复。这是我的代码
let path = docDir.stringByAppendingPathComponent(dbName)
let fm = NSFileManager.defaultManager()
if !(fm.fileExistsAtPath(path)) {
if let from = (NSBundle.mainBundle().resourcePath! as NSString).stringByAppendingPathComponent(dbName)
{
var error:NSError?
do {
try fm.copyItemAtPath(from, toPath: path)
} catch let error1 as NSError {
error = error1
print("SQLiteDB - failed to copy writable version of DB!")
print("Error - \(error!.localizedDescription)")
return
}
}
}
错误在线
if let from = (NSBundle.mainBundle().resourcePath! as NSString).stringByAppendingPathComponent(dbName)
报告错误:
条件绑定的初始化器必须是 Optional 类型,而不是 'String'
请有人帮助我。非常感谢
【问题讨论】:
标签: swift2