[MacRuby-devel] How to retrieve an observer's context?
Edward Hynes
ehynes at dharmagaia.com
Mon Apr 20 08:57:55 PDT 2009
I'd like to use contexts when registering some observers, but have
been unable to retrieve them, getting a "can't convert C/Objective-C
value `0x2822731' of type `v' to Ruby object" instead. The following
code, for example, will trigger the error
class Subject
attr_accessor :abc
end
class Observer
def observeValueForKeyPath keyPath, ofObject:object, change:change,
context:context
context[0]
end
end
subject = Subject.new
observer = Observer.new
subject.addObserver observer, forKeyPath:'abc', options:0, context:'a
context'
subject.setAbc 'some value'
Is there a way to retrieve an observation context? Or is there an
alternative way for observers to distinguish among multiple
registrations for a given object/keyPath?
Thanks,
Ed
More information about the MacRuby-devel
mailing list