[MacRuby-devel] [MacRuby] #252: Support key-value observing via the attr_accessor family of methods
MacRuby
ruby-noreply at macosforge.org
Wed Apr 21 12:44:21 PDT 2010
#252: Support key-value observing via the attr_accessor family of methods
------------------------------------------------+---------------------------
Reporter: jvoorhis@… | Owner: lsansonetti@…
Type: enhancement | Status: closed
Priority: minor | Milestone: MacRuby 0.6
Component: MacRuby | Resolution: fixed
Keywords: key-value observing, attr_accessor |
------------------------------------------------+---------------------------
Changes (by martinlagardette@…):
* status: new => closed
* resolution: => fixed
* milestone: => MacRuby 0.6
Comment:
It is now supported with MacRuby. You can check with the nightlies.
However, please be aware that for notifications to work as expected, you
will have to call #framework at least once:
{{{
# /tmp/kvn.rb
framework 'Foundation'
class Notifier
attr_accessor :value
end
class Observer
def observeValueForKeyPath(path, ofObject:object, change:change,
context:context) puts change end
end
n = Notifier.new
n.addObserver(Observer.new, forKeyPath:'value', options:0, context:nil)
n.value = 42
n.setValue 42
}}}
{{{
$> macruby /tmp/kvn.rb
{"kind"=>1}
{"kind"=>1}
$>
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/252#comment:1>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list