Re: IBOutlet getter/setter pattern question
Re: IBOutlet getter/setter pattern question
- Subject: Re: IBOutlet getter/setter pattern question
- From: Matt Neuburg <email@hidden>
- Date: Thu, 20 Oct 2011 09:59:09 -0700
On Tue, 18 Oct 2011 11:00:49 -0700, Eeyore <email@hidden> said:
>When I declare something as an IBOutlet, am I exposing it to others?
IBOutlet is not a "declaration" in any meaningful sense. It's just a bit of internal fluff with Xcode; the compiler never sees it. It makes no difference whatever to the status of your ivars / properties.
Since ivars are private, they are not "exposed to others" in any case. In iOS 5 you can even put the ivar declarations in the @implementation section to keep them out of the header file (assuming you're not synthesizing them, in which case there are no ivar declarations) - this, however, is a purely stylistic matter, having nothing to do with what is *actually* exposed (i.e. it doesn't alter their privacy status).
Properties are public if they're declared in the header, but they can be declared in the implementation file instead (using e.g. a class extension block), thus making them private as well, in the sense that any other class trying to use these properties will be warned by the compiler.
It seems to me, then, that the only problem you're really having is related not to exposure but to the time-sequence. You know you're going to use the ivar to set some features of nib-loaded instances *once*, during viewDidLoad, and never again. You're feeling like having a pointer to these instances after that moment makes no sense, since you're never going to use it for anything. But:
(1) These can be assign (weak) properties, because the instances are retained by the view hierarchy. Thus these ivars are mere pointers. There really is no overhead involved. There was never any need to retain them, release them in viewDidUnload, release them in dealloc, etc. (If you use ARC there's no visible overhead / buttressing even if you do happen to retain them.)
(2) If it really really bothers you that you're pointing to them needlessly, you could nilify the pointers at the end of viewDidLoad. Now you're not pointing to them any more. I don't quite see what good this would accomplish, but there's no harm in it.
However, it does seem to me that the real key to happiness for you is probably using the numeric tags. :)
m.
--
matt neuburg, phd = email@hidden, <http://www.apeth.net/matt/>
A fool + a tool + an autorelease pool = cool!
Programming iOS 4!
http://www.apeth.net/matt/default.html#iosbook_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden