开发者

Why doesn't the default XCode Window based application template create the window programmatically?

开发者 https://www.devze.com 2023-02-06 03:26 出处:网络
I\'m just starting out with objective c, iphone, and xcode dev.The default template has UIWindow *window as a member variable but I never see it initialized like:

I'm just starting out with objective c, iphone, and xcode dev. The default template has UIWindow *window as a member variable but I never see it initialized like:

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

which I'm confused as to why. Do we not need to do that b开发者_Python百科ecause the window is already creaqted in the nib file? Thank you very much everyone.


If you look at your app delegate's header file, just beneath the @interface part, you see this:

@property (nonatomic, retain) IBOutlet UIWindow *window;

This connects the window property to the window object in your nib file, so it's already created within the nib file and there's no need to allocate a new UIWindow object. Your app delegate simply looks in the nib file and uses the object in there.

0

精彩评论

暂无评论...
验证码 换一张
取 消