Realm fileExists siempre es cierto
Quiero copiar un archivo de dominio precargado, así que hago:
Copié mi archivo al navegador de proyectos llamadodefault.realm
. Luego verifique sifileExists:
:
let bundlePath = Bundle.main.path(forResource: "default", ofType: "realm")
let destPath = Realm.Configuration.defaultConfiguration.fileURL?.path
let fileManager = FileManager.default
if fileManager.fileExists(atPath: destPath!) {
//File exist, do nothing
print("File exist")
} else {
do {
//Copy file from bundle to Realm default path
try fileManager.copyItem(atPath: bundlePath!, toPath: destPath!)
print("Copied")
} catch {
print("\n",error)
}
}
Y siempre devuelve verdadero, por lo que no puedo copiar mi archivo de reino.