Created
January 1, 2009 01:35
-
-
Save drnic/42172 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns the persistent store coordinator for the application. This | |
# implementation will create and return a coordinator, having added the | |
# store for the application to it. (The folder for the store is created, | |
# if necessary.) | |
def persistentStoreCoordinator | |
if @persistentStoreCoordinator | |
return @persistentStoreCoordinator | |
end | |
error = Pointer.new_with_type('@') | |
fileManager = NSFileManager.defaultManager | |
applicationSupportFolder = self.applicationSupportFolder | |
if !fileManager.fileExistsAtPath(applicationSupportFolder, isDirectory:nil) | |
fileManager.createDirectoryAtPath(applicationSupportFolder, attributes:nil) | |
end | |
url = NSURL.fileURLWithPath(applicationSupportFolder.stringByAppendingPathComponent("Grokking Recipes.xml")) | |
options = { NSMigratePersistentStoresAutomatically: NSNumber.numberWithBool(true)} | |
@persistentStoreCoordinator = NSPersistentStoreCoordinator.alloc.initWithManagedObjectModel(self.managedObjectModel) | |
if !@persistentStoreCoordinator.addPersistentStoreWithType(NSXMLStoreType, configuration:nil, URL:url, options:options, error:error) | |
NSApplication.sharedApplication.presentError(error[0]) | |
end | |
return @persistentStoreCoordinator | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment