Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
606 views
in Technique[技术] by (71.8m points)

objective c - Universal iPhone/iPad AppDelegate

I was wondering if anyone would be able to tell me, starting a new app from scratch, how would I organise having a universal (iPhone/iPad) iOS app. I noticed using the default template with the Xcode Beta, it gives you both a shared AppDelegate and subclassed appdelegates for iPhone and iPad.

Now, how do you put in the logic to determine which app delegate to use, how does it know which one to instantiate and work with as the default template doesn't state. If I were to write in the iPhone appDelegate, how do I know that this will only run for the iPhone iOS for example?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The Info.plist ("Main nib file base name") for an app specifies a main window .xib file to load, and that .xib file specifies an app delegate and root window controller for the app.

The Info.plist for an iPad ("NSMainNibFile~ipad") additionally specifies a main window .xib file for the iPad, which can contain a different app delegate and a different root window controller for the app. Or they could be the same ones, using runtime UIUserInterfaceIdiomPad checks.

The runtime, which knows what device type on which it's running, picks the correct initial .xib file to load from the info.plist, and from there you get the correct app delegate and root window controller configured and running.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...