Database created with Core Data on Swift

Asked

Viewed 494 times

0

I need to create an app that is a form with basic data (name, age, email, etc.) and that saves the data for access later, but that in addition to saving in the tableView, create the database file or spreadsheet. I saw that Coredata and Realm generated a DB file.

They can tell me how to access this file, or how to create it, if this is not done automatically with the Coredata import in the project?

I already have an app with Coredata deployed and that saves notes that write the lists in a tablView, but I need to change them to a form and that generates this file in DB format to backup the data.

Thank you very much, guys!

1 answer

0

So both Realm and Coredata create a file in the App directory:

~/Library/Developer/CoreSimulator/Devices/[DeviceID]/data/Containers/Data/Application/[AppID]/Documents/

In this directory you can have access to .db from your database.

To have access to this directory just access by Nsfilemanager:

let documents = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false)

This will return a list of directories, but you need to take only the first one, after that just list the files and get the one you want.

I really like using Coredata but I suggest you use Realm for simplicity and being quick to work.

If you use the existing name that lib to back it up to iCloud Drive.

I hope I helped you =D

  • Helped Victor too much! Thank you so much! As soon as I have enough reputation, I will vote for your reply! Thank you very much!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.