2015-08-27 Open underlying SQLite database when using Core Data

During development of an app using Core Data, you often want to have a quick peep in the underlying SQLite store. Paste the following bit somewhere in your AppDelegate:

	// Log path (to manually open SQLite database) when in simulator. In the File -> Open dialog of
	// SQLPro for SQLite, type Shift-CMD-G and paste this path
	if TARGET_IPHONE_SIMULATOR == 1 {
		let path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).last! as! String
		println("Documents folder: \(path)")
	}

You can use the commandline sqlite client, but I like SQLPro for SQLite. Start your app, copy the string from the console in Xcode, then go to SQLPro and click the Open button. In the dialogue, type Shift-Cmd-G and you can paste the path of the Document folder of your currently running app. You can then open the SQLite database and peek inside.