Re: Why does Xcode define IBOutlet with @synthesize?
Re: Why does Xcode define IBOutlet with @synthesize?
- Subject: Re: Why does Xcode define IBOutlet with @synthesize?
- From: Quincey Morris <email@hidden>
- Date: Fri, 23 Sep 2011 15:57:49 -0700
On Sep 23, 2011, at 15:24 , Jerry Krinock wrote:
> When creating a new project in Xcode 4.1, I get a window which is declared in the app delegate as:
>
> @property (assign) IBOutlet NSWindow *window;
>
> and defined as
>
> @synthesize window ;
>
> Is this not going to create unnecessary unnecessary setter and getter implementations? Would not @dynamic be more appropriate in this situation?
a. What do you mean by "unnecessary"? Your choices for an outlet are pretty much ivar or property. Are you suggesting the property is "unnecessary" because it could be an ivar instead? If the window reference is strictly private to the app delegate, then an ivar might be a better choice. If it's public, the property is a better choice.
b. @dynamic isn't magic. It says the methods are provided by something else (other than user-written implementations or @synthesized implementations). What's the something else you're thinking of here?
c. IAC, I'd maintain that the template is worthless in this regard, for anything but toy apps. In real apps, you'd almost certainly want to move the window to its own nib file instead of having it dumped in the menu nib file, and you'd almost certainly want to create a window controller for it.
Thus, the app delegate reference would be a window controller (and not an outlet, obviously). But the same ivar vs property considerations would still apply to the delegate.
_______________________________________________
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