[MacRuby-devel] Overriding +autosavesInPlace

Keith Gautreaux keith.gautreaux at gmail.com
Sat Oct 8 08:36:34 PDT 2011


I'm not a Macruby expert and I don't know anything about Cocoa,
particularly as it relates to new Lion features such as autosave, but
the example code you gave is defining an instance method, not a class
method.

To override a class method you would need to do something like:

class MyDocument < NSPersistentDocument

...

  def self.autosavesInPlace
    return YES
  end
end

There are other ways of defining class methods but this is the easiest
when you just have one method.

HTH

On Sat, Oct 8, 2011 at 10:25 AM, Sven A. Schmidt <sas at abstracture.de> wrote:
> Hi all,
>
> I'm trying to add autosave and versions to an application and as far as I can tell from the docs it should be as simple as overriding +(BOOL)autosavesInPlace to return YES from my core data document application. So what I have is essentially:
>
> class MyDocument < NSPersistentDocument
>
>  ...
>
>  def autosavesInPlace
>    return YES
>  end
>
> end
>
> However, I don't get autosave or versions behavior (i.e. I've still got the "dirty dot", no versions menu in the title bar etc). Also, autosavesInPlace doesn't seem to get called. When I print a log message in there it never shows up in the console.
>
> Should this be working the way I'm doing it? Unfortunately, I don't have a Cocoa application to compare (yet) so I'm not sure if I'm doing something wrong at the frameworks end or on the MacRuby side.
>
> One thing I was wondering (since I'm rather new to both Ruby and MacRuby): I'm overriding a class method here (+(BOOL), not -(BOOL)), is there anything special I need to consider when doing this from MacRuby?
>
> Cheers,
> Sven
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>



-- 
Keith


More information about the MacRuby-devel mailing list