File=>New=>Project
选择iOS下的Application里面的Empty Application
输入工程名字,如HelloWorld,选择一个保存位置,确定即可。
三个源文件:
AppDelegate.h/AppDelegate.m/main.m,其中
1) AppDelegate.h:
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
2) AppDelegate.m:
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window=_window;
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOption:(NSDictonary *)launchOptions
{
self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
-(void)applicationWillResignActive:(UIApplication *)application
{
}
-(void)applicationDidEnterBackground:(UIApplication *)application
{
}
-(void)applicationWillEnterForeground:(UIApplication *)application
{
}
-(void)applicationDidBecomeActive:(UIApplication *)application
{
}
-(void)applicationWillTerminate:(UIApplication *)application
{
}
3)main.m
#import <UIKit/UIKit>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool{
return UIApplicationMain(argc, argv, nil, NSStringFromClass({AppDelegate class]));
}
}