KVO++?

I think it could be useful to have a shortcut added to Objective-C which combines a keyword value observer relationship with an automatic assignment on value change.

It could be noted syntactically using a new assignment operator (=> in my example below):

SomeObject *foo = [SomeObject new];
AnotherObject *bar = [AnotherObject new];
bar.property => foo.changingProperty;

The goal would be to build an automatic connection such that whenever the value of “changingProperty” is modified for object “foo”, object “bar” gets a message equivalent to: [bar setProperty:foo.changingProperty].

This is, of course, not without potential difficulties. For example, a deeper property reference would mean more cases to automatically observe:

bar.property => foo.changingProperty.anotherProperty;

In that case, there should probably be two observers - one for foo.changingProperty and another for (obj).anotherProperty. If “changingProperty” modifies it’s value, then the new resulting value object needs to be observed for changes to it’s “anotherProperty” property, and finally the original assignment to bar.property would be re-issued with the new value.

(Note: Not saying my assignment operator is awesome.. it was just something to use in an example. :))

2 Responses to “KVO++?”

  1. James Says:

    Hi, I found your blog on this new directory of WordPress Blogs at blackhatbootcamp.com/listofwordpressblogs. I dont know how your blog came up, must have been a typo, i duno. Anyways, I just clicked it and here I am. Your blog looks good. Have a nice day. James.

  2. Jeff Says:

    This conversation reminds me of the ultra-cool Sabifoo.. which I’m still hoping you’ll bring back one day! (or at least give up the code so we can put a version out there!)