Skip to content

Instantly share code, notes, and snippets.

@kastiglione
Created October 4, 2012 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kastiglione/3836448 to your computer and use it in GitHub Desktop.
Save kastiglione/3836448 to your computer and use it in GitHub Desktop.
Setup a minimal NSIncrementalStore subclass for learning / experimenting with MacRuby
framework 'CoreData'
# Create a minimal model
$thing = NSEntityDescription.alloc.init
$thing.name = 'Thing'
$model = NSManagedObjectModel.alloc.init
$model.entities = [$thing]
# Create the custom store class
class CustomStore < NSIncrementalStore
def loadMetadata(error)
self.metadata = {NSStoreTypeKey => 'CustomStore', NSStoreUUIDKey => '0123456789ABCDEF'}
true
end
end
# Register the custom store class
NSPersistentStoreCoordinator.registerStoreClass(CustomStore, forStoreType:'CustomStore')
# Create the store via a PSC
$coordinator = NSPersistentStoreCoordinator.alloc.initWithManagedObjectModel($model)
$custom_store_error = Pointer.new(:object)
$custom_store = $coordinator.addPersistentStoreWithType('CustomStore', configuration:nil, URL:nil, options:nil, error:$custom_store_error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment