On Jun 17, 2010, at 8:41 PM, Charles Srstka wrote:

> On Jun 17, 2010, at 8:19 PM, Matt Neuburg wrote:
> 
>> On or about 6/17/10 5:56 PM, thus spake "Roland King" <r...@rols.org>:
>> 
>>> if ... you just have a class variable called <key> or _<key> then the
>>> whole array is not replaced, the method you call on 
>>> NSMutableArrayValueForKey:
>>> is passed through to that underlying variable which does what you might 
>>> expect
>>> and operates on the array variable directly.
>>> 
>>> That's not such a rare case.
>> 
>> In fact it is exactly the case I had in mind. :) That's really just what I
>> wanted to hear. Someone asked "how do you think the proxy object works";
>> that *is* how I was thinking it might work. Thx - m.
> 
> The problem with things like this is the way it destroys encapsulation.

Exactly.

Matt, if you have a to-many relationship property, do you make the return type 
of the getter NSMutableArray*?  I should hope not, or you're asking for 
problems.

Therefore, why did you "want[...] to hear" that KVC would do the rough 
equivalent?  It's a terrible idea to let KVC access instance variables 
directly.  My firm belief is that Apple only maintains that "feature" for 
backwards compatibility.

I never subclass NSObject directly.  Instead, I have a custom subclass of 
NSObject one of whose main purposes is to override 
+accessInstanceVariablesDirectly to return NO.  Likewise, whenever I subclass 
other framework classes, I install such an override, too.  Because of that, I 
mentally excise the direct-ivar-access steps from the KVC accessor search 
patterns.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to