Coding

How to manually access Core Date / SQLite file in Xcode 6/IOS 8 Swift Programming

by
published on
This is very easy. Just open
AppDeligate.swift
In the delegate try to find the  method called
var applicationDocumentsDirectory: NSURL {
Add a println for the URL
// Returns the URL to the application's Documents directory.

    var applicationDocumentsDirectory: NSURL {
        let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
           
 println(urls);

        return urls[urls.count-1] as NSURL

    }

Now each time you use the Core Data framework you should be able to see the path in your console. Something like this should be printed on your console.

[file:///Users/kaushik/Library/Developer/CoreSimulator/Devices/D7C02C00-5656569-48CA-84D5-4EB5Aere9941/data/Containers/Data/Application/BCA8er3C-5769-4067-B1er5-F91345Cwewe828B/Documents/]

The reason you can see the path in this way is because the manageContextObject method uses the above method to generate/access the SQLite file