Tôi đang cố gắng để sao chép một tập tin từ Bundle App của tôi để các thiết bị và tôi nhận được một lỗi lạ: cannot convert the expression type '$T5' to type 'LogicValue'
lỗi Swift FileManager khi sao chép tập tin từ Bundle
tôi nhận xét dòng đó gây ra các vấn đề trong mã bên dưới.
Dưới đây là tất cả mọi thứ:
// This function returns the path to the Documents folder:
func pathToDocsFolder() -> String {
let pathToDocumentsFolder = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
return pathToDocumentsFolder.stringByAppendingPathComponent("/moviesDataBase.sqlite")
}
override func viewDidLoad() {
super.viewDidLoad()
let theFileManager = NSFileManager.defaultManager()
if theFileManager.fileExistsAtPath(pathToDocsFolder()) {
println("File Found!")
// And then open the DB File
}
else {
// Copy the file from the Bundle and write it to the Device:
let pathToBundledDB = NSBundle.mainBundle().pathForResource("moviesDB", ofType: "sqlite")
let pathToDevice = pathToDocsFolder()
let error:NSError?
// Here is where I get the error:
if (theFileManager.copyItemAtPath(pathToBundledDB, toPath:pathToDevice, error:error)) {
// success
}
else {
// failure
}
}
}
App thậm chí sẽ không biên dịch ngay bây giờ. Sự cố có vẻ như cụ thể với cuộc gọi copyItemAtPath
- đó là nghĩa vụ trả lại một Bool.
Tôi đánh giá cao bất kỳ thông tin chi tiết nào.
thanks bro !!!!! – sirab333