Warning: Undefined variable $post in /home/naoooooo8/naoya-ono.com/public_html/swift/wp-content/themes/sango-theme-poripu/functions.php on line 12

Warning: Attempt to read property "ID" on null in /home/naoooooo8/naoya-ono.com/public_html/swift/wp-content/themes/sango-theme-poripu/functions.php on line 12

【iOSアプリ開発】Realmファイル「default.realm」の保存先の確認方法

記事内に商品プロモーションを含む場合があります

Realmを使って登録したデータの中身を確認したい場合、Realm Studioなどのツールで「default.realm」を開くことで確認できます。

この「default.realm」の場所を確認するには、Appdelegate.swiftに次のようにファイルのパスを表示するコードを書けばOKです。

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  
  // パスを確認するコード
  print(Realm.Configuration.defaultConfiguration.fileURL!)

do {
  let realm = try Realm()
} catch {
   print("Error initialising new reaml, \(error) ")
}
  return true
}

実際にプログラムを動かすと、このようにファイルのパスが表示されます。

コメントを残す

メールアドレスが公開されることはありません。 ※ が付いている欄は必須項目です

CAPTCHA