On Jul 30, 2013, at 8:48 AM, Andy Lee wrote: > On Jul 30, 2013, at 11:25 AM, Scott Ribe <scott_r...@elevated-dev.com> wrote: >> On Jul 30, 2013, at 9:08 AM, Andy Lee <ag...@mac.com> wrote: >> >>> I think it's subject to the same criticisms as *any* direct access to >>> ivars, although I agree it feels sketchier when done in plain C for some >>> reason. >> >> Yes. Because what is the point of plain C functions in Objective-C files? >> Local helpers that are not OOP, and do not go through method dispatch >> overhead. To turn around and inject direct access to ivars in those is >> really mixing metaphors. > > One reason people might directly access ivars applies to methods as well as > functions: the class may not have a getter method for that ivar. Now, there > is a school of thought that says ivars should *always* be accessed via a > getter method, except in init and dealloc, and if necessary a "private" > getter should be added. If one does not subscribe to that school of thought, > and accesses ivars directly in methods, I personally don't think it's a > *huge* deal to do so in functions, especially since the function has to be > inside the @implementation section and it won't be a commonplace thing. But > as always, I'm happy to code to the accepted norms of whatever team I'm on.
I'd go for [foo valueForKey:@"privateIvar"] over foo->privateIvar. > >>> Which reminds me... instance methods can also directly access the ivars of >>> *other* instances of the same class. >> >> Now, *that* I knew. I'm sorry senator, I cannot recall if I ever did such a >> thing. But I knew it was possible ;-) > > So noted, and we thank you for your testimony today. :) > > --Andy > > > _______________________________________________ > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/lrucker%40vmware.com > > This email sent to lruc...@vmware.com _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com