Re: Which thing should be an IBOutlet?
Re: Which thing should be an IBOutlet?
- Subject: Re: Which thing should be an IBOutlet?
- From: Christiaan Hofman <email@hidden>
- Date: Tue, 11 Dec 2012 23:15:01 +0100
On Dec 11, 2012, at 22:44, Steve Mills wrote:
> Which should be the IBOutlet for connecting a control in a nib to its owner class? The instance variable:
>
> @interface Blah
> {
> IBOutlet Thing* thing;
> }
>
> @property (assign) Thing* thing;
> @end
>
> Or the property:
>
> @interface Blah
> {
> Thing* thing;
> }
>
> @property (assign) IBOutlet Thing* thing;
> @end
>
> Or both:
>
> @interface Blah
> {
> IBOutlet Thing* thing;
> }
>
> @property (assign) IBOutlet Thing* thing;
> @end
>
> I've seen examples of the first two.
Certainly not both. The other two are both OK. But I would say that putting it at the property is preferred. Think of when the two ways are not equivalent. E.g. when the ivar name is different from the property name:
@interface Blah
{
Thing* _thing;
}
@property (assign) IBOutlet Thing* thing;
@end
In that case the outlet you should see in IB should be named "thing" and not "_thing", the ivar name is really just an implementation detail while the property name is API. Even clearer would be when the property is not even associated to an ivar directly (it could be a property of an ivar, or a field in a struct, or an item in a C-array). So this way is more generally applicable, and in case of conflict the appropriate way, therefore it's generally the preferred way.
Christiaan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden