[MacRuby-devel] How to retrieve an observer's context?

Edward Hynes ehynes at dharmagaia.com
Mon Apr 20 19:23:25 PDT 2009

Hi Laurent,

Thanks for the help.  Did you mean to set the context ivar on the  
observer or on the subject?  Wouldn't setting it on the observer  
result in the last registration 'winning' if the observer is watching  
more than one subject?


On Apr 20, 2009, at 4:28 PM, Laurent Sansonetti wrote:

> Hi Edward,
> Context arguments in Objective-C are generally void pointers, which  
> makes them hard to use in Ruby. Also, since we run in Objective-C GC  
> mode, objects could potentially be collected since contexts do not  
> set up AFAIK write barriers.
> I would recommend to set up an instance variable on your observer  
> instead (and pass nil as the context).
>  observer.instance_variable_set(:@context, your_context)
> And later in your observer method, retrieve the ivar.
> Laurent

More information about the MacRuby-devel mailing list