How can I check what is stored in my Core Data Database?

后端 未结 17 2201
北恋
北恋 2020-12-12 14:35

I am making an app that relies on Core Data. I am able to enter data into a text field and store it.

But I need to know if the data is being stored.

I am try

17条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 14:55

    The other solutions are either old or does not direct you easily or quickly to the SQLite files, so I came up with my own solution using FileManager.SearchPathDirectory.applicationSupportDirectory that gets the exact path where the sqlite file will be.

    func whereIsMySQLite() {
        let path = FileManager
            .default
            .urls(for: .applicationSupportDirectory, in: .userDomainMask)
            .last?
            .absoluteString
            .replacingOccurrences(of: "file://", with: "")
            .removingPercentEncoding
    
        print(path ?? "Not found")
    }
    

    whereIsMySQLite() will print the path which you can simply copy-paste on your Mac here:

    Finder > Go > Go to folder

提交回复
热议问题