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]));
}
}
本文详细介绍了如何使用Xcode创建一个基本的iOS应用程序。通过创建一个名为HelloWorld的空项目,文章逐步解释了三个核心源文件AppDelegate.h、AppDelegate.m及main.m的作用与实现方式,并展示了如何设置项目的初始界面。


被折叠的 条评论
为什么被折叠?



