Digging a bit more I think a solution to my own questions is:

On 13 May 2010, at 14:33, Dave Baldwin wrote:

> 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"

SKTWindowControllerCanvasSizeObservationContext = Pointer.new(:char)

as all we are after is a unique value.  I still don't understand why the 
original version wasn't acceptable as the documentation says the context 
argument can be a C pointer or an object reference.  Anyhow, this has got me 
past this point but I have still to prove the final result when it is used by 
the observer.

> 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.
> 
> 

Dave.

_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to