For the More Curious: What about main()?

When you began learning C and Objective-C, you learned that the entry point into your program’s code is the main() function. It’s absolutely true in Cocoa / Cocoa Touch development as well, although it’s extremely rare to edit this function in Cocoa and Cocoa Touch applications. Open main.m, and you’ll see why:

r​e​t​u​r​n​ ​U​I​A​p​p​l​i​c​a​t​i​o​n​M​a​i​n​(​a​r​g​c​,​ ​a​r​g​v​,​ ​n​i​l​,​ ​N​S​S​t​r​i​n​g​F​r​o​m​C​l​a​s​s​(​[​B​N​R​A​p​p​D​e​l​e​g​a​t​e​ ​c​l​a​s​s​]​)​)​;​

Well, that was anti-climactic. Only one line of actual code.

The UIApplicationMain() function creates the necessary objects for your application to run. First, it creates a single instance of the UIApplication class. Then, it creates an instance of whatever class is denoted by the fourth and final argument and sets it to be the application’s delegate, so that it can send its delegate messages when memory gets low, when the application is quit or backgrounded, or when it finishes launching.

And that’s the trail from main() to application:didFinishLaunchingWithOptions: and your custom code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset