Swift初体验之HelloWord+苹果Swift编程语言新手教程【中文版】

AppDelegate.swift :

<span style="font-size:24px;"><strong>//
//  AppDelegate.swift
//  SwiftHelloWord
//
//  Created by jason on 14-6-5.
//  Copyright (c) 2014年 JasonApp. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?

) -> Bool {
        // Override point for customization after application launch.
        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:.
    }

}
</strong></span>

ViewController.swift :

<span style="font-size:24px;"><strong>//
//  ViewController.swift
//  SwiftHelloWord
//
//  Created by jason on 14-6-5.
//  Copyright (c) 2014年 JasonApp. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet var swiftLabel : UILabel

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    @IBAction func swiftButtonPressed(sender : UIButton) {

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
</strong></span>

Main.storyboard:

下载:

苹果Swift编程语言新手教程【中文版】.pdf

时间: 2024-07-30 13:47:21

Swift初体验之HelloWord+苹果Swift编程语言新手教程【中文版】的相关文章

Swift初体验之HelloWord+苹果Swift编程语言入门教程【中文版】

AppDelegate.swift : <span style="font-size:24px;"><strong>// // AppDelegate.swift // SwiftHelloWord // // Created by jason on 14-6-5. // Copyright (c) 2014年 JasonApp. All rights reserved. // import UIKit @UIApplicationMain class AppD

Swift初体验 (一)

// 声明一个常量 let maxNumberOfStudents: Int = 47 // 声明一个变量,如果没有在声明的时候初始化,需要显示的标注其类型 var currentNumberOfStudents = 23 // 使用前必须初始化 currentNumberOfStudents += 1 // 浮点数据自动推断为Double类型,如果需要指定了Float类型,需要显示的指定Float类型 let score: Float = 90.5; let englishScore = 80

Swift初体验(二)

// 函数写法初体验 func getMyName(firstName first:String, lastName last:String) -> String{ //return first + "-" + last return first + last } var myName = getMyName(firstName: "hu", lastName: "mingtao") println("myName = \(myN

Swift初体验(三)

/*******************************************************************************/ // 协议 protocol Description{ func description() -> String mutating func aMutatingMethod() class func aTypeMethod() // func anOptionalMethod() } // 如果要声明可选择实现的方法,需要在func前

苹果Swift编程语言新手教程【中国版】

Swift代码语言教程:在刚刚过去的WWDC2014大会上,苹果公司新公布了一种编程语言Swift.据悉.Swift语言继承了C语言以及Objective-C的特性,且克服了C语言的兼容性问题.对于广大开发人员来说,这无疑是一剂难以抗拒的兴奋剂.希望苹果Swift编程语言新手教程[中文版],能助你更迅速掌握好它. 注:本文从苹果官方所公布的书籍<The Swift Programming Language>中摘录和提取而成. 希望对各位的iOS&OSX开发有所帮助.[苹果官方教程下载地

Apple Swift编程语言新手教程

Apple Swift编程语言新手教程 作者: 日期: gashero 2014-06-03 FROM:http://gashero.iteye.com/blog/2075324 文件夹 1   简单介绍 2   Swift入门 3   简单值 4   控制流 5   函数与闭包 6   对象与类 7   枚举与结构 1   简单介绍 今天凌晨Apple刚刚公布了Swift编程语言,本文从其公布的书籍<The Swift Programming Language>中摘录和提取而成.希望对各位的

swift初体验

swift是一门类型安全的语言,同样也是基于c语言 那么c语言的一些类型也是实用的,不同的是:swift声明变量和常量是不一样的 let:用来修饰常量:var用来修饰变量 e.g: let num=111 var num2=222 num=12  就会报错 num2=123 就可以正常通过 在没有固定类型的时候,let和var 声明的类型是万能的,系统会根据后面的参数类型来确定参数类型 我们可以使用如下方法来声明一个确定类型的变量和常量 let  num : Int =111 let  num2

Swift初体验之图案锁

这篇在应用上貌似没有价值,貌似我写了好多实际上都没有价值,这里贴出来就是分享下. 自己写swift好多天了,感觉好多东西还是不太懂,边学边做,互勉! 先上图: 代码:下载

Swift 编程语言新手教程

今天在网上看到一篇很好的教程,分享给大家 原文地址:http://gashero.iteye.com/blog/2075324 文件夹 1   简单介绍 2   Swift入门 3   简单值 4   控制流 5   函数与闭包 6   对象与类 7   枚举与结构 1   简单介绍 今天凌晨Apple刚刚公布了Swift编程语言,本文从其公布的书籍<The Swift Programming Language>中摘录和提取而成.希望对各位的iOS&OSX开发有所帮助. Swift是供