print(Realm.Configuration.defaultConfiguration.fileURL)
→ Use the above code to figure out where your Realm file is.
CMD + SHIFT + G (Finder)
→ to immediately navigate to the path printed in the console. (delete "file://").
let data = Data()
data.name = "Kevin"
data.age = 26
do {
let realm = try Realm()
try realm.write {
realm.add(data)
}
} catch {
print("Error initializing realm \(error)")
}
Initializing Realm for basic use
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
print(Realm.Configuration.defaultConfiguration.fileURL)
do {
let realm = try Realm()
} catch {
print("Error initializing realm \(error)")
}
return true
}