为什么当我打开现有的realm数据库时总是为零结果

时间:2017-05-18 03:36:00

标签: swift realm xcode8

为什么当我打开现有的realm数据库时总是为零结果

composer init

当我用

打电话时
 func chekDB() {
    let bundleDB = Bundle.main.path(forResource: "Conversio", ofType: "realm")
    let desPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first!
    let fileManager = FileManager.default
    let fullDesPath = URL(fileURLWithPath: desPath).appendingPathComponent("Conversio.realm")
    let fullDestPathString = String(describing: fullDesPath)
    if fileManager.fileExists(atPath: fullDesPath.path){
        print("Database file is exis !")
        print(fileManager.fileExists(atPath: bundleDB!))
    }else{
        do{
            try fileManager.copyItem(atPath: bundleDB!, toPath: fullDesPath.path)
        }catch{
            print("error encured while copying file to directori \(fullDestPathString)")
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您应该指定领域文件路径来打开您的领域文件:

<select [compareWith]="compareFn"  [(ngModel)]="selectedCountries">
  <option *ngFor="let country of countries" [ngValue]="country">
    {{country.name}}
  </option>
</select>

// define this function in your component
compareFn(c1: Country, c2: Country): boolean {
  return c1 && c2 ? c1.id === c2.id : c1 === c2;
}

了解更多https://realm.io/docs/swift/latest/#realms