Apple推出了基于Objective-C的新语言Swift. 通过实例, 我们可以很好的感受这门新语言

注意事项: 在XCode6_Beta中, 如果有中文, IDE的自动补全功能就会失效, 所以开始调试的时候可以先用英文, 后面再用中文替代.

1. 新建iOS -> Single View Application.

2. 修改AppDelegate.swift文件

 //
// AppDelegate.swift
// UIByCode_Swift_1_HelloWorld
//
// Created by yao_yu on 14-6-18.
// Copyright (c) 2014 yao_yu. All rights reserved.
// import UIKit @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
// Override point for customization after application launch.
let window = self.window!
window.backgroundColor = UIColor.whiteColor()
window.makeKeyAndVisible() let frame = UIScreen.mainScreen().bounds
let EDGE:CGFloat = var labelHello = UILabel(frame: CGRectMake(EDGE, (frame.height - EDGE)/, frame.width - EDGE * , EDGE))
labelHello.textAlignment = NSTextAlignment.Center
labelHello.text = "你好,欢迎来到swift世界!" //加入中文后,XCode的自动补全功能就不出来了
window.addSubview(labelHello) return true
} func applicationWillResignActive(application: UIApplication) {
// 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.
} func applicationDidEnterBackground(application: UIApplication) {
// 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.
} func applicationWillEnterForeground(application: UIApplication) {
// 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.
} func applicationDidBecomeActive(application: UIApplication) {
// 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.
} func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
} }

3.运行

最新文章

  1. CoreCRM 开发实录——开始之新项目的技术选择
  2. 快速学习C语言三: 开发环境, VIM配置, TCP基础,Linux开发基础,Socket开发基础
  3. 20145212 《Java程序设计》第5周学习总结
  4. tony_nginx_02_URL重写
  5. iOS 中不同的modalPresentationStyle对parent view 的影响
  6. json一些特点
  7. js----全局变量和局部变量部分讲解
  8. Hao123这个流氓
  9. MXF素材文件交换格式深入研究
  10. APIO2015题解
  11. xampp下安装yii框架下遇到的问题
  12. HA for openstack
  13. .Net 4.0特性 Tuple元组
  14. cookie和session的区别(搜狐笔试考到的一个题目)
  15. 数字图像处理(MATLAB版)学习笔记(1)——第1章 绪言
  16. linux下swoole的安装
  17. Spring装配Bean之Java代码装配bean
  18. 2456: mode
  19. 如何利用JavaScript遍历JSON数组
  20. jeecg入门操作—树型表单开发

热门文章

  1. 《Effective C++》学习笔记条款13 以对象管理资源
  2. JMeter入门(1):JMeter总体介绍及组件介绍
  3. TM1668 Led 驱动芯片源程序
  4. Vim程序编辑器
  5. WTL 自定义 Button类-自绘
  6. JS 判断 Radio 单选按钮是否为选中状态 并弹出 值信息
  7. U3D 精灵的点击监听
  8. jQuery中的on()和click()的区别 分类: 前端 HTML jQuery 2014-11-06 10:26 96人阅读 评论(0) 收藏
  9. Js 上传文件 页面不刷新
  10. linux rman shell