Understanding main.m in Objective-C

Maker QR Code in Objective-C Understanding main.m

Understanding main.m
QR-Code Creator In Objective-C
Using Barcode generation for iPhone Control to generate, create QR image in iPhone applications.
www.OnBarcode.com
European Article Number 13 Creator In Objective-C
Using Barcode maker for iPhone Control to generate, create EAN / UCC - 13 image in iPhone applications.
www.OnBarcode.com
The first file created by Xcode is main.m, which contains the main function. main.m comes with standard code preinstalled for you, as you can see here:
Paint Barcode In Objective-C
Using Barcode creator for iPhone Control to generate, create Barcode image in iPhone applications.
www.OnBarcode.com
Create USS Code 39 In Objective-C
Using Barcode creator for iPhone Control to generate, create Code 39 Extended image in iPhone applications.
www.OnBarcode.com
#import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; }
EAN / UCC - 14 Encoder In Objective-C
Using Barcode generation for iPhone Control to generate, create EAN / UCC - 13 image in iPhone applications.
www.OnBarcode.com
QR Code 2d Barcode Encoder In Objective-C
Using Barcode printer for iPhone Control to generate, create QR Code JIS X 0510 image in iPhone applications.
www.OnBarcode.com
The creation of this main routine is automatic, and you generally shouldn t have to fool with it at all. But it s worth understanding what s going on. You start with an #import directive, which you ll recall is Objective-C s substitute for #include. More specifically, you include the UIKit framework, the most important framework in Objective-C. This isn t needed, because it s also in the Prefix.pch file; but at least at the time of this writing, it s part of the default main.m file. You next create an NSAutoreleasePool. Recall that we mentioned this in our discussion of memory management in the previous chapter. It s what supports the NSObject s autorelease method. Also note that you release the pool after you ve run your application s main routine, following the standard rule that if you allocate the memory for an object, you must also release it. The UIApplicationMain line creates your application and kicks off the event cycle. The function s arguments look like this:
Draw Code 128 Code Set C In Objective-C
Using Barcode drawer for iPhone Control to generate, create Code 128 Code Set B image in iPhone applications.
www.OnBarcode.com
GTIN - 12 Drawer In Objective-C
Using Barcode generation for iPhone Control to generate, create GTIN - 12 image in iPhone applications.
www.OnBarcode.com
int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName );
QR Code Creator In Visual C#.NET
Using Barcode drawer for Visual Studio .NET Control to generate, create QR Code ISO/IEC18004 image in .NET framework applications.
www.OnBarcode.com
Encoding Denso QR Bar Code In Objective-C
Using Barcode generation for iPhone Control to generate, create QR image in iPhone applications.
www.OnBarcode.com
As with the rest of the main.m file, you should never have to change this. But we nevertheless briefly touch on what the latter two arguments mean although they ll usually be set to their defaults, thanks to the nil arguments.
Denso QR Bar Code Printer In .NET Framework
Using Barcode encoder for ASP.NET Control to generate, create Denso QR Bar Code image in ASP.NET applications.
www.OnBarcode.com
EAN / UCC - 13 Drawer In Java
Using Barcode generator for BIRT reports Control to generate, create EAN / UCC - 13 image in BIRT reports applications.
www.OnBarcode.com
Download from Wow! eBook <www.wowebook.com>
Encode Barcode In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Create 2D In Visual Studio .NET
Using Barcode maker for VS .NET Control to generate, create Matrix Barcode image in .NET applications.
www.OnBarcode.com
Using Xcode
Create Code 39 In None
Using Barcode generator for Software Control to generate, create Code 3 of 9 image in Software applications.
www.OnBarcode.com
Printing Barcode In .NET
Using Barcode generator for Reporting Service Control to generate, create Barcode image in Reporting Service applications.
www.OnBarcode.com
principalClassName defines the application s main class, which is UIApplication by default. This class does a lot of the action- and event-controlling for your program, topics that we ll return to in chapter 6. The UIApplication object is created as part of this startup routine, but you ll note that no link to the object is provided. If you need to access it (and you will), you can use a UIApplication class method to do so:
Barcode Creation In Visual C#
Using Barcode creation for VS .NET Control to generate, create Barcode image in VS .NET applications.
www.OnBarcode.com
Barcode Creator In Java
Using Barcode drawer for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
[UIApplication sharedApplication];
Scan Code 3 Of 9 In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Barcode Scanner In Java
Using Barcode Control SDK for Java Control to generate, create, read, scan barcode image in Java applications.
www.OnBarcode.com
This returns the application object. It s typically sent as part of a nested message to a UIApplication method, as you ll see in future chapters. For now, the application does two things of note: it calls up your default .xib file, and it interfaces with your application delegate. The delegateClassName defines the application object s delegate, an idea introduced in chapter 2. As noted there, this is the object that responds to some of the application s messages, as defined by the UIApplicationDelegate protocol. Among other things, the application delegate must respond to lifecycle messages: most important, the applicationDidFinishLaunching: message, which runs your program s content, as we ll talk more about momentarily. In Xcode s templates, delegate class files always have the name projectAppDelegate. Your program finds them, thanks to a delegate property that s built into Interface Builder. You could change the arguments sent to UIApplicationMain, and you could add other commands to the main.m file, but generally you don t want to. The defaults should work fine for any program you re likely to write in the near future. Let s put main.m away for now and turn to the file where any programming starts: your application delegate.
Understanding the application delegate
As you ve already seen, the application delegate is responsible for answering many of the application s messages. You can refer to the previous chapter for a list of some of the more important ones or to Apple s UIApplicationDelegate protocol reference for a complete listing. More specifically, an application delegate should do the following: At launch time, it must create an application s windows and display them to the user. It must initialize your data. It must respond to quit requests. It must handle low-memory warnings. Of these topics, the first is of importance to you now. Your application delegate files, helloworldxcAppDelegate.h and helloworldxcAppDelegate.m, get your program started.
Copyright © OnBarcode.com . All rights reserved.