Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 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
Add Comment
Please, Sign In to add comment