Guest User

Untitled

a guest
Feb 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. # Returns the persistent store coordinator for the application. This
  2. # implementation will create and return a coordinator, having added the
  3. # store for the application to it. (The folder for the store is created,
  4. # if necessary.)
  5. def persistentStoreCoordinator
  6. if @persistentStoreCoordinator
  7. return @persistentStoreCoordinator
  8. end
  9.  
  10. error = Pointer.new_with_type('@')
  11.  
  12. fileManager = NSFileManager.defaultManager
  13. applicationSupportFolder = self.applicationSupportFolder
  14.  
  15. if !fileManager.fileExistsAtPath(applicationSupportFolder, isDirectory:nil)
  16. fileManager.createDirectoryAtPath(applicationSupportFolder, attributes:nil)
  17. end
  18.  
  19. url = NSURL.fileURLWithPath(applicationSupportFolder.stringByAppendingPathComponent("Grokking Recipes.xml"))
  20. options = { NSMigratePersistentStoresAutomatically: NSNumber.numberWithBool(true)}
  21. @persistentStoreCoordinator = NSPersistentStoreCoordinator.alloc.initWithManagedObjectModel(self.managedObjectModel)
  22. if !@persistentStoreCoordinator.addPersistentStoreWithType(NSXMLStoreType, configuration:nil, URL:url, options:options, error:error)
  23. NSApplication.sharedApplication.presentError(error[0])
  24. end
  25.  
  26. return @persistentStoreCoordinator
  27. end
Add Comment
Please, Sign In to add comment