sto cercando di copiare un file dal mio Bundle di App per il dispositivo e sto ottenendo uno strano errore: cannot convert the expression type '$T5' to type 'LogicValue'
errore Swift FileManager durante la copia di file da Bundle
ho commentato la linea che sta causando il problema in il codice qui sotto.
Ecco tutto:
// 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
}
}
}
L'App non sarà nemmeno compilare al momento. Il problema sembra essere specificamente con la chiamata copyItemAtPath
, che dovrebbe restituire un Bool.
Apprezzerei qualsiasi approfondimento.
grazie fratello !!!!! – sirab333