[MacRuby-devel] Core Data brain-o

Joshua Ballanco jballanc at gmail.com
Mon Mar 21 08:52:53 PDT 2011


Just to clarify the reason behind this, in Ruby 1.9 { foo:bar } translates
into { :foo => bar }. Since you want a has using constants as keys, the
shorthand notation doesn't work. In other words, your first example
translates to:

psc_options = { :NSMigratePersistentStoresAutomaticallyOption =>
NSNumber.numberWithBool(true),
                        :NSInferMappingModelAutomaticallyOption =>
NSNumber.numberWithBool(true) }

On Sat, Mar 19, 2011 at 7:54 PM, Morgan Schweers <cyberfox at gmail.com> wrote:

> Greetings,
> I was trying to set up automatic migration, and did this brain-o, which
> will be obvious to most folks, but stumped me for a little bit:
>
>     psc_options = {
> NSMigratePersistentStoresAutomaticallyOption:NSNumber.numberWithBool(true
> ),
>
>
>  NSInferMappingModelAutomaticallyOption:NSNumber.numberWithBool(true) }
>
>     fail(error) unless at persistentStoreCoordinator.addPersistentStoreWithType(NSSQLiteStoreType,
>
>
> configuration:nil, URL:url,
>
>
> options:psc_options, error:error)
>
>
> When what I should have been doing was something like:
>
>     psc_options = {}
>
>     psc_options[NSMigratePersistentStoresAutomaticallyOption] =
> NSNumber.numberWithBool(true)
>
>     psc_options[NSInferMappingModelAutomaticallyOption] =
> NSNumber.numberWithBool(true)
>
>     ...
>
>
> ...or even...
>
>
>     psc_options = { NSMigratePersistentStoresAutomaticallyOption =>
> NSNumber.numberWithBool(true),
>
>                     NSInferMappingModelAutomaticallyOption =>
> NSNumber.numberWithBool(true) }
>
>
> It's subtle bugs like these that make me slap my head...
>
>
> ...but now Core Data automatic migration works!  W00t!
>
>
> --  Morgan
>
>
> p.s. If you're trying to do Core Data migration, I found this article
> particularly useful:
> http://www.timisted.net/blog/archive/core-data-migration/
>
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110321/4fdbee20/attachment.html>


More information about the MacRuby-devel mailing list