问题描述
所以我想弄清楚我的快速IOS应用程序将SQLite数据库文件存储在哪里。我知道ApplicationsDocumentsDirectory存储该目录。我需要找到一种在控制台或NSLog中进行打印的方法。我是Swift和iOS开发的新手,所以在这里遇到了麻烦。我尝试只在另一个类中调用变量,也只是在clojure中将其NSLogging失败了。有什么想法吗?
So I want to figure out where my swift IOS app is storing its SQLite db file. I know that the applicationsDocumentsDirectory stores the directory. I need to find a way to print it in the console or NSLog it. I am new to swift and IOS development so I'm having trouble here. I tried just calling the variable in another class and also just NSLogging it within the clojure with no success. Any ideas?
这里是变量。
lazy var applicationDocumentsDirectory: NSURL = {
// The directory the application uses to store the Core Data store file. This code uses a directory named "arux-software.onsite_childcare" in the application's documents Application Support directory.
let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
return urls[urls.count-1] as NSURL
}()
推荐答案
有一个获取sqlite位置:
There is an easier way to get the sqlite location:
println(NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString)
提供没有时间戳的输出,如下所示:
gives output with no time stamp like this:
/Users/tooti/Library/Developer/CoreSimulator/Devices/AB5B3350-F891-420B-88D5-E8F8E578D39B/data/Containers/Data/Application/38FBDC42-0D09-4A10-A767-17B576882117/Documents
和
NSLog(NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString )
提供带有时间戳的输出,例如:
gives output with a time stamp, like this:
2015-01-23 23:31:57.373 RAACTutor[6551:140531] /Users/tooti/Library/Developer/CoreSimulator/Devices/AB5B3350-F891-420B-88D5-E8F8E578D39B/data/Containers/Data/Application/38FBDC42-0D09-4A10-A767-17B576882117/Documents
这篇关于Swift中的NSlogging / println SQLite db文件位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!