ben at tanjero.com
Mon Oct 6 10:31:25 PDT 2008
>> I don't entirely understand KVC yet, and from what I understood the
>> standard ruby attr_accessor would be enough to handle it. I'll try
>> adding the extra methods.
> I think it depends on the way in which the key is being accessed.
> Sounds like the key you are accessing is being accessed as a
> collection (thus the need for these methods).
> If it was a simple property:
> attr_accessor :employees
> Would have been sufficient
As Brad pointed out, you don’t need all the extra methods. The
downside of the single accessor is that the original collection for
the property will be thrown out every time, which can cause a bit of
churn if you do anything with the data in your setter (subscribe to
KVO notifications for each individual object, for instance). The extra
methods simply let you provide more fine-grained access to your
backing store to the KVC machinery.
More information about the MacRuby-devel