iOS project file main.m is actually an OC a class of. m files, why we can not see this file immediately when the file is an OC class. m file?
Since 1. OC Class General first Letter capital
2.OC classes typically have. h files
First, the main.m file in Xcode7.3 's new project.
#import <uikit/uikit.h>//loaded into the Uikit frame UIKit.h file, in fact, only for a UIApplication.h uiapplicationmain C language function
#import "AppDelegate.h"//loading AppDelegate.h file, in fact, only for one OC method Nsstringfromclass required Parameters--, personal feeling all sorts of fuss over
The code is as follows |
Copy Code |
int main (int argc, char * argv[]) { @autoreleasepool { According to the information printed on the console: NSLog (@ "argc =%d", argc);//int argc is 1. NSLog (@ "argv[] count =%lu", sizeof (argv)/sizeof (argv[0));//c char array count is 1 NSLog (@ "argv[0] =%s", argv[0]);//print string knowable argv[0] is a path
NSLog (@ "Bundlepath =%@", [NSBundle Mainbundle].bundlepath);//And [NSBundle Mainbundle].bundlepath print results comparison, argv[0] = = [ NSBundle Mainbundle].bundlepath is True To learn more about ARGC,ARGV can refer to the following URLs Http://wenku.baidu.com/link?url=xNNFYFd3kGS0fj79e_hKbQnnO6t_ Tiubln8dmunq-k7oqyj9uftzy5hppkcwkku3ck1eyacmg8ybrpmh5vtdushsl_em2nrqi0bjlgcl5dy Return Uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([Appdelegate class]);//uiapplicationmain returns a number of type int, Nsstringfromclass ([Appdelegate class]) in fact, the return value of this method is a NSString object @ "Appdelegate", can be directly written as @ "Appdelegate" } } |
Console information:
The code is as follows |
Copy Code |
ARGC = 1 argv[] Count = 1 Argv[0] =/library/developer/coresimulator/devices/ea9e0ae1-9ee8-4246-aa72-f39ed66fd2f7/data/containers/bundle/ Application/ae119964-3712-4c12-8fa7-acb8d663e59b/testapp.app/testapp Bundlepath =/library/developer/coresimulator/devices/ea9e0ae1-9ee8-4246-aa72-f39ed66fd2f7/data/containers/ Bundle/application/ae119964-3712-4c12-8fa7-acb8d663e59b/testapp.app Omit some personal information |
Super Lite version main.m (test can run the program correctly)
code is as follows |
copy code |
#import <uikit/uiapplication.h> int main (int argc, char * argv[]) { @autoreleasepool { return Uiapplicationmain (argc, argv, nil, @ "appdelegate"); } } |