Swift 是什么,大家都回去百度或者Google,有的甚至认为是Taylor Swift(她是我的偶像),但是如果今天在百度百科里搜索绝对没有说是Apple最新推出的编程语言,因为是在2014年6月3日凌晨1点多(北京时间)在2014年WWDC上发布的,它会在未来逐步替代Objective-C开发语言,这让我们学了Objective-C的人又要学习新的编程语言,给大家看张图片:这是大家的感受!

但是我们还要去学习Swift!毕竟未来不落后这个时代!

Swift是什么?

Swift是苹果于WWDC 2014发布的编程语言,这里引用The Swift Programming Language的原话:

Swift is a new programming language for iOS and OS X apps that builds on the best of C and Objective-C, without the constraints of C compatibility.

Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible and more fun.

Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to imagine how software development works.

Swift is the first industrial-quality systems programming language that is as expressive and enjoyable as a scripting language.

简单的说:

  1. Swift用来写iOS和OS X程序。(估计也不会支持其它屌丝系统)
  2. Swift吸取了C和Objective-C的优点,且更加强大易用。
  3. Swift可以使用现有的Cocoa和Cocoa Touch框架。
  4. Swift兼具编译语言的高性能(Performance)和脚本语言的交互性(Interactive)。

Swift语言概览

 // Playground - noun: a place where people can play

 import Cocoa

 var str = "Hello, playground"
var str1 = "Hello Wrold!!!"
var str2 = "O(∩_∩)O哈哈~" // Hello, world
println("Hello, world") // 变量与常量
// Swift 使用 var 声明 变量 , let 声明常量
var myVariable =
myVariable =
let myConstant = // 类型推导
let explicitDouble : Double = // Swift 不支持隐式 类型转换 (所以需要显式类型转换)
let label = "The width is"
let width =
let width1 = label + String(width) // 使用 \(item) 的形式进行 字符串格式化
let apples =
let orages =
let sum = "I have \(apples) apples."
let sum1 = "I have \(apples + orages) pieces of fruit." // 数组和字典
// Swift 使用[] 操作符声明 数组(array)和字典 (dictionary)
var listArr = ["fish","water","apple","rice"]
listArr[] = "bottle of water" var dict = [
"name": "melody",
"age" : "", ]
dict["sex"] = "female" // 一般使用初始化器(initializer)语法创建空数组和空字典 let emptyArray = String[]()
let emptyDict = Dictionary<String, Float>()

看看我在Xcode 6上编程的效果:

这个我也在学习,希望大家多多支持,多多在文章下写评论和点推荐,我的邮箱为lkvt@sina.com!

Swift 编程语言自己实践 -自己在Xcode6 动手写20140603的更多相关文章

  1. Swift 语言概览 -自己在Xcode6 动手写1

    原文:Swift 语言概览 -自己在Xcode6 动手写1 Swift是什么? Swift是苹果于WWDC 2014发布的编程语言,这里引用The Swift Programming Language ...

  2. Swift 语言概览 -自己在Xcode6 动手写2-tableView

    import UIKit class ViewController: UIViewController ,UITableViewDelegate, UITableViewDataSource { va ...

  3. Apple Swift编程语言入门教程

    Apple Swift编程语言入门教程 作者: 日期: 布衣君子 2015.09.22 目录 1   简介 2   Swift入门 3   简单值 4   控制流 5   函数与闭包 6   对象与类 ...

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

    Swift代码语言教程:在刚刚过去的WWDC2014大会上,苹果公司新公布了一种编程语言Swift.据悉.Swift语言继承了C语言以及Objective-C的特性,且克服了C语言的兼容性问题.对于广 ...

  5. [转]Swift 编程语言入门教程

    今天在网上看到一篇非常好的教程,分享给大家 原文地址:http://gashero.iteye.com/blog/2075324 目录 1   简介 2   Swift入门 3   简单值 4   控 ...

  6. Swift 编程语言新手教程

    今天在网上看到一篇很好的教程,分享给大家 原文地址:http://gashero.iteye.com/blog/2075324 文件夹 1   简单介绍 2   Swift入门 3   简单值 4   ...

  7. Apple Swift编程语言入门

    1   简单介绍 今天凌晨Apple刚刚公布了Swift编程语言,本文从其公布的书籍<The Swift Programming Language>中摘录和提取而成.希望对各位的iOS&a ...

  8. Swift 编程语言入门教程

    1   简介 今天凌晨Apple刚刚发布了Swift编程语言,本文从其发布的书籍<The Swift Programming Language>中摘录和提取而成.希望对各位的iOS& ...

  9. Apple Swift编程语言新手教程

    文件夹 1   简单介绍 2   Swift入门 3   简单值 4   控制流 5   函数与闭包 6   对象与类 7   枚举与结构 1   简单介绍 今天凌晨Apple刚刚公布了Swift编程 ...

随机推荐

  1. 394. Decode String

    [题目] Total Accepted: 10087 Total Submissions: 25510 Difficulty: Medium Contributors: Admin Given an ...

  2. TF400324: Team Foundation services are not available from server…

    Quick Fix As a quick fix you can Close Visual Studio and related apps Browse to %LocalAppData%\Micro ...

  3. Windows环境下MongoDB的安装与配置

    MongoDB是一种高性能的文档型数据库,现介绍一下在Windows环境下MongDB的安装与配置 获取MongoDB 打开官方网站 www.mongodb.org,找到页面右上解的DownLoad链 ...

  4. math and date、ajax、画布

    console.log(Math.PI);//圆周率 console.log(Math.sqrt(4));//平方根2 console.log(Math.abs(-2.3));//绝对值2.3 con ...

  5. IE关闭兼容性视图

    不知道什么时候,ie8的“兼容性视图设置”变成了灰色,如图:  今天通过设置组策略,终以解决了这个问题: ie8的兼容性视图设置灰色的解决办法:运行gpedit.msc--用户配置/计算机配置--管理 ...

  6. 利用Volley封装好的图片缓存处理加载图片

    Volley 工具箱中提供了一种通过 DiskBasedCache 类实现的标准缓存.这个类能够缓存文件到磁盘的指定目录.但是为了使用 ImageLoader,我们应该提供一个自定义的内存 LRC b ...

  7. Linux快捷键和别名

    一.设置别名 1使用命令行     alias 别名='命令'(只对本次登陆生效) 2.使用配置文件设置别名(永久生效) vi /root/.bashrc        打开系统别名配置文件,一般是用 ...

  8. Nutch2.x

    http://www.micmiu.com/opensource/nutch/nutch2x-tutorial/

  9. linux -a 到 -z 的意义

    shell if判断中常用的也就是绿色部分,尾部部分越看越不懂.从百度文库转载. [ -a FILE ] 如果 FILE 存在则为真. [ -b FILE ] 如果 FILE 存在且是一个块特殊文件则 ...

  10. Theoretical comparison between the Gini Index and Information Gain criteria

    Knowledge Discovery in Databases (KDD) is an active and important research area with the promise for ...