[MacRuby-devel] Using a context with addObserver

Dave Baldwin dave.baldwin at dsl.pipex.com
Thu May 13 06:33:47 PDT 2010


I am trying to translate code that looks like this:

static NSString *SKTWindowControllerCanvasSizeObservationContext = @"com.apple.SKTWindowController.canvasSize";

and later

[[self document] addObserver:self forKeyPath:SKTDocumentCanvasSizeKey options:NSKeyValueObservingOptionNew context:SKTWindowControllerCanvasSizeObservationContext];

to Ruby:

SKTWindowControllerCanvasSizeObservationContext = "com.apple.SKTWindowController.canvasSize"
document.addObserver(self, forKeyPath: SKTDocumentCanvasSizeKey, 
						options: NSKeyValueObservingOptionNew,
						context:SKTWindowControllerCanvasSizeObservationContext)

but when it runs I get this error:

 expected instance of Pointer, got `"com.apple.SKTWindowController.canvasSize"' (String) (TypeError)

How do I get the a pointer to the context string?  All the examples I have found for the Pointer class seem to expect an objective C routing to fill it in.

Thanks,

Dave.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20100513/d3fb2d6a/attachment.html>


More information about the MacRuby-devel mailing list