Boid Boid - 2 months ago 26
iOS Question

NSlogging/println SQLite db file location in Swift

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?

Here is the variable.

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


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:



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