swift语言ios开发 第一个程序hello world!

老实说:第一个swift语句的ios不是代码敲出来的,我甚至还没来得急看代码,hello world 就出来了。。。。。

 

本人开发环境:mac osx 10.10 dp1 + xcode beta + swift(更低xcode不支持swift语言)

 

思路与大致过程:

       1、建立工程,工程包含界面文件,代码文件等等

        2、在工程的界面文件中加入text控件,用于显示hello world

        3、输入hello world ,模拟运行

 

 

让我们一步一步来:

  1、建立工程,工程包含界面文件,代码文件等等

点击 File-new-project 创建工程

 

 

 

 2、选择工程类型  我们选择single  view application(单视图应用)

 

 

 

3、对工程进行配置如图  选择swift语言

 

 

 

4、点击next 选择工程代码等文件存放地点

存放在我的文档,点击creat按钮

 

 

5、创建成功后在左边视图中展开工程文件,看到一个Main.storyboard,这就是界面控制视图文件,用来设计软件界面的,我们单击之(双击会将该面板作为独立窗口显示,不方便添加控件):

 

 

6、单击main.storyboard后显示:

 

 

7、在右下角面板中选择第三个按钮,得到控件列表 如下图红色笔记

 

 

 

 

选择该按钮后下面是控件列表,滚动鼠标下拉找到text控件,拉到窗口中即可

 

 

 

9、然后点击文本框,输入fuck swift 即可,点击左上角运行按钮即可编译运行(编译需要短暂时间):

 

10、结果图

 

 

因为这个程序太简单,所以整个过程就没代码什么事情.......

 

打个小广告:本人精通各类操作系统的安装与维护,包括在普通pc机(联想宏碁等)安装mac os x系统(还有大把软件),100元/次不二价,欢迎北京朋友咨询qq1752209254

有意请短信先咨询:18510222924 

ps :支持多系统安装,即开机时可选择进入哪个操作系统(win+linux各种版本+mac os x)

本教程截图就是黑苹果机子。。

// // main.m // Hello World_Code // #import #import "AppDelegate.h" int main(int argc, char *argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } } // // AppDelegate.h // Hello World_Code // #import @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; @end // // AppDelegate.m // Hello World_Code // #import "AppDelegate.h" @implementation AppDelegate - (void)dealloc { [_window release]; [super dealloc]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(320/2.0 - 140/2.0, 80, 140, 40)]; // 1 label.text = @"Hello World"; label.backgroundColor = [UIColor cyanColor]; label.textAlignment = NSTextAlignmentCenter; [self.window addSubview:label]; // 2 [label release]; // 1 return YES; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值