Tôi đã thử nghiệm nó trên XCode 8 Swift 3 hệ điều hành MacOS Sierra
IOS 10
In Your Appdelegate.swif t
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. Consta nt .documentDirectory
nói rằng chúng ta đang tìm kiếm tài liệu thư mục
2. Hằng số .userDomainMask
để hạn chế tìm kiếm của chúng tôi để sandbox ứng dụng của chúng ta.
đầu ra
file:///Users/Ashok/Library/Developer/CoreSimulator/Devices/F629F99F-C745-46EB-8A11-01BC9FF1E592/data/Containers/Data/Application/3B373C93-71A2-46E9-8AF7-EF407C39429F/Documents/
Bấm vào Bắt đầu -> Go to Folder -> Paste Path -> Nhấn Enter
Sau đó Tới Library -> Ứng dụng Hỗ trợ -> filename.sqlite
Sửa
HOẶC
mở terminal và gõ find ~ -name 'HitTest.sqlite'
và nhấn 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
Từ trên đầu ra bạn có thể thấy rõ con đường của SQLite db của bạn
Bạn có thể sử dụng DB Browser for SQLite để mở.
Nguồn
2016-10-18 08:44:25
Cảm ơn bạn đã trả lời. Tôi đã thử nó nhưng nó không hoạt động. Tôi đặt dưới các đối số thông qua khi khởi động, -com.apple.CoreData.SQLDebug 1, nhưng điều này không in bất cứ điều gì. Bạn có biết tại sao ? –
@IdanAviv: Xem http://stackoverflow.com/a/39679571/1187415. –
Cảm ơn Martin! –