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
656 views
in Technique[技术] by (71.8m points)

objective c - Is there any reason to modify the main.m file in your iOS applications?

I'm trying to get a better understanding of the purpose of each file contained in a basic iOS application.

Is there any reason to modify the main.m file? I'm wondering if that file ever needs to be touched. If you do modify it, why?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

In 99.9% of all cases, there is no need to touch main.m.

In the other 0.1%, you might want to change the arguments of the call to the UIApplicationMain() function. The last two arguments of this function specify the names of the classes that represent your main application (UIApplication by default) and the application delegate.

Should you ever decide to subclass UIApplication, you would set the third argument to the name of your subclass. Subclassing UIApplication can be useful if you want to intercept certain events your app handles (override sendEvent:).

The name of your app delegate class might change if you simply decide to rename that class. Also, if the fourth argument to UIApplicationMain() is nil (which is the default in project templates that do not use Storyboarding in iOS 5), it signifies that you create your app delegate object in your app's main NIB file. Should you ever decide to change that decision (e.g., to adapt Storyboarding for an existing project), you would have to change the fourth argument in order to tell UIApplicationMain() the name of the class it should instantiate.


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

...