核心数据文件的位置 iOS 10 [英] Core Data file's Location iOS 10
问题描述
我正在尝试使用 SQLite 浏览器查看我的核心数据对象.我无法找到核心数据在哪里保存其 sql 文件.我查看了应用程序文档文件夹,但那里什么也没有.
I am trying to us SQLite Browsers to see my Core Data objects. I am not able to find where does the core data save its sql file. I looked into the app documents folder but there is nothing there.
你知道IOS 10(模拟器)中的核心数据在哪里保存它的SQLite文件吗?
Do you know where does the core data in IOS 10(simulator) save its SQLite files on?
推荐答案
我在 XCode 8 Swift 3 OS macOS Sierra 上测试过
I tested it on XCode 8 Swift 3 OS macOS Sierra
IOS 10
在你的 Appdelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
print(urls[urls.count-1] as URL)
return true
}
1.常量 .documentDirectory
表示我们正在寻找 Document 目录
1. The constant .documentDirectory
says we are looking for Document directory
2.常量 .userDomainMask
将我们的搜索限制在应用程序的沙箱中.
2. The constant .userDomainMask
to restrict our search to our application's sandbox.
输出
file:///Users/Ashok/Library/Developer/CoreSimulator/Devices/F629F99F-C745-46EB-8A11-01BC9FF1E592/data/Containers/Data/Application/3B373C93-71A2-46E9-8AF7-EF407C39429F/Documents/
点击 Go -> Go to Folder -> Paste Path -> 按 Enter
然后转到库 -> 应用程序支持 -> filename.sqlite
已编辑
或
打开你的终端并输入 find ~ -name 'HitTest.sqlite'
然后回车.
open your terminal and type find ~ -name 'HitTest.sqlite'
and hit enter.
Ashoks-MacBook-Pro:Desktop Ashok$ find ~ -name 'HitTest.sqlite'
/Users/Ashok/Library/Developer/CoreSimulator/Devices/F629F99F-C745-46EB-8A11-01BC9FF1E592/data/Containers/Data/Application/3B373C93-71A2-46E9-8AF7-EF407C39429F/Documents/HitTest.sqlite
从上面的输出你可以清楚地看到你的sqlite db的路径
您可以使用 DB Browser for SQLite 打开.
这篇关于核心数据文件的位置 iOS 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!