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

简介: AppDelegate.swift : //// AppDelegate.swift// SwiftHelloWord//// Created by jason on 14-6-5.

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

相关文章
|
9月前
|
Unix 调度 Swift
苹果iOS新手开发之Swift 中获取时间戳有哪些方式?
在Swift中获取时间戳有四种常见方式:1) 使用`Date`对象获取秒级或毫秒级时间戳;2) 通过`CFAbsoluteTimeGetCurrent`获取Core Foundation的秒数,需转换为Unix时间戳;3) 使用`DispatchTime.now()`获取纳秒级精度的调度时间点;4) `ProcessInfo`提供设备启动后的秒数,不表示绝对时间。不同方法适用于不同的精度和场景需求。
295 3
|
5月前
|
机器学习/深度学习 人工智能 移动开发
Swift语言作为苹果公司推出的现代编程语言
Swift语言作为苹果公司推出的现代编程语言
98 8
|
5月前
|
安全 开发工具 Swift
Swift 是苹果公司开发的现代编程语言,具备高效、安全、简洁的特点,支持类型推断、闭包、泛型等特性,广泛应用于苹果各平台及服务器端开发
Swift 是苹果公司开发的现代编程语言,具备高效、安全、简洁的特点,支持类型推断、闭包、泛型等特性,广泛应用于苹果各平台及服务器端开发。基础语法涵盖变量、常量、数据类型、运算符、控制流等,高级特性包括函数、闭包、类、结构体、协议和泛型。
121 2
|
5月前
|
存储 Swift 开发者
Swift 是一种现代编程语言,支持面向对象编程(OOP),包括类、对象、继承、多态等核心概念
Swift 是一种现代编程语言,支持面向对象编程(OOP),包括类、对象、继承、多态等核心概念。通过这些特性,Swift 能够帮助开发者构建结构清晰、可维护性强的代码。本文介绍了 Swift 中 OOP 的基本概念、高级特性和实际应用,并通过一个简单的 `Car` 类示例展示了如何在 Swift 中实现面向对象编程。
61 1
|
7月前
|
安全 编译器 Swift
探索iOS开发之旅:Swift编程语言的魅力与挑战
【9月更文挑战第5天】在iOS应用开发的广阔天地中,Swift作为苹果官方推荐的编程语言,以其简洁、高效和安全的特点,成为了开发者的新宠。本文将带领你领略Swift语言的独特魅力,同时探讨在实际开发过程中可能遇到的挑战,以及如何克服这些挑战,成为一名优秀的iOS开发者。
|
9月前
|
Swift iOS开发 Kotlin
苹果iOS新手开发之Swift中实现类似Kotlin的作用域函数
Swift可通过扩展实现类似Kotlin作用域函数效果。如自定义`let`, `run`, `with`, `apply`, `also`,增强代码可读性和简洁性。虽无直接内置支持,但利用Swift特性可达成相似功能。
116 7
|
9月前
|
调度 Swift Android开发
苹果iOS新手开发之Swift中的并发任务和消息机制
Swift的消息机制类似Android的Handler,实现任务调度有三种方式: 1. **Grand Central Dispatch (GCD)**:使用`DispatchQueue`在主线程或后台线程执行任务。 2. **OperationQueue**:提供高级接口管理`Operation`对象。 3. **RunLoop**:处理事件如输入源、计时器,类似Android的`Looper`和`Handler`。 **示例**: - GCD:在不同线程执行代码块。 - OperationQueue:创建操作并执行。 - RunLoop:用Timer添加到RunLoop中。
154 2
|
9月前
|
安全 编译器 Swift
苹果重磅发布Swift 6:在 Swift 6 中如何实现并发开发?相比Swift 5.5 有哪些重磅升级?
Swift 6 强化了并发编程,引入结构化并发、任务、执行器、隔离、同步原语、类型化错误处理和取消超时功能。对比Swift 5.5,它默认启用全面并发检查,改进错误处理,增加了隔离区域、类型化抛出、包迭代等新特性,优化了性能并更新了库。
209 2
|
10月前
|
移动开发 安全 Swift
TIOBE 6月榜单:Swift强势挺进,编程语言版图的悄然变革
【6月更文挑战第21天】**TIOBE 6月榜:Swift晋升至第12,凸显其在苹果生态和移动开发中的重要性。自2014年发布以来,Swift凭借强类型、内存安全等特性赢得开发者青睐。排名上升源于苹果支持、开源跨平台、教育普及及性能提升。Swift的崛起影响行业生态,提升开发效率,预示着语言生态、跨平台和教育先行的趋势。未来,Swift有望扩展到更多领域,持续优化并深化教育影响。**
306 6
|
11月前
|
存储 Swift
在Swift编程语言中,Set
在Swift编程语言中,Set
100 2
下一篇
oss创建bucket