Isn't it already working? At least for primitiv types?

Eg. when I bind a label to a Int property which i change with a slider bind to the same property i don't need additional code for KVO.

Cheers
Thilo


On 13.05.2009 22:31 Uhr, Jeremy Voorhis wrote:
I've created a ticket at https://www.macruby.org/trac/ticket/252. I
might be wrong as I am still grokking the Objective-C runtime, but it
seems to me that this should be easy to implement if attr_accessor and
attr_writer generate the setKey: method first and then implement #key=
in terms of setKey:. Is there some requirement that key-value setter
methods return void, or is that just by convention?

Best,

Jeremy

On Wed, May 13, 2009 at 12:00 PM, Laurent Sansonetti
<lsansone...@apple.com>  wrote:
Hi Jeremy,

That's a pretty good idea! Could you file a bug on the tracker so that we do
not forget about it?

Thanks,
Laurent

On May 12, 2009, at 10:18 AM, Jeremy Voorhis wrote:

Hello,

I've been learning Cocoa, Objective-C and macruby in tandem and I was
just wondering, are there any plans to integrate the key-value
observing protocol with the attr_accessor family of methods? With a
little experimentation, I found KVO is definitely possible with
macruby, but the syntax is less than ideal (transcript made with the
0.4 release).

~ % macirb
class Notifier
  attr_accessor :value
end
=>  nil
class Observer
  def observeValueForKeyPath(path, ofObject:object, change:change,
context:context) puts change end
end
=>  nil
n = Notifier.new
=>  #<Notifier:0x8005e91a0>
n.addObserver(Observer.new, forKeyPath:'value', options:0, context:nil)
=>  nil
n.value = 42
=>  42
n.setValue 42
{"kind"=>1}
=>  nil

Best,

Jeremy Voorhis
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to