Re: Newbie Q: Why is UIWindow in the AppDelegate not an ivar?
Re: Newbie Q: Why is UIWindow in the AppDelegate not an ivar?
- Subject: Re: Newbie Q: Why is UIWindow in the AppDelegate not an ivar?
- From: "Debajit Adhikary" <email@hidden>
- Date: Sun, 14 Dec 2008 15:19:55 -0800
It turns out the window can in fact be accessed as
[[UIApplication sharedApplication] keyWindow] // readonly property
On Sat, Dec 13, 2008 at 7:45 PM, Luke Hiesterman <email@hidden> wrote:
> Generally speaking you will do well for yourself to follow Apple's example
> over Erica's. I haven't actually read her book but I've had several examples
> come to my attention of where she doesn't do things in the best way.
>
> Erica is a talented hacker but please get in the habit of following the
> canonical examples. These have been thoroughly vetted and approved my many
> experts.
>
> Luke
>
> Sent from my iPhone.
>
>
> On Dec 13, 2008, at 7:22 PM, Debajit Adhikary <email@hidden> wrote:
>
> I meant to ask what the tradeoffs are between declaring the UIWindow
>> object
>> as an instance variable in the AppDelegate vs. as a local object in
>> -applicationDidFinishLaunching:
>>
>> The specific example I'd mentioned was from Erica Sadun's book, and
>> looking
>> at Apple's sample code, and the code that XCode generates, it seems that
>> the
>> UIWindow object is typically declared as an instance variable in the
>> AppDelegate and seems the way to go (as opposed to Erica Sadun's example
>> of
>> using a local UIWindow object).
>>
>>
>> On Sat, Dec 13, 2008 at 6:34 PM, Debajit Adhikary <email@hidden
>> >wrote:
>>
>> When you create an iPhone app, in the AppDelegate, why is the
>>> UIWindow created locally within -applicationDidFinishLaunching and not
>>> declared
>>> as an ivar? The functionality does not seem to change either way. I'd
>>> like to know how one approach is better than the other.
>>>
>>> What I presume is that the window object really doesn't need to be
>>> accessed
>>> from outside later. But doesn't declaring it as an ivar make it more
>>> accessible from the "outside" allowing greater application extensibility?
>>>
>>> @implementation AppDelegate
>>>
>>> - (void) applicationDidFinishLaunching:(UIApplication*) application
>>> {
>>> UIWindow* window = ... ;
>>> [window addSubView: ...];
>>> [window makeKeyAndVisible];
>>> }
>>>
>>> ...
>>> @end
>>>
>>>
>>> _______________________________________________
>>
>> 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
>>
>
_______________________________________________
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