上回书说道:灰常灰常基本的数据类型
下面咱们来点高级的:
Tuples 元组
元组存储一对键值,并且没有类型限制
let http404Error = (404, "Not Found")
// http404Error is of type (Int, String), and equals (404, "Not Found")书上废话一堆,反正元组就是这么写,上面的例子还...
分类:
其他好文 时间:
2014-07-01 06:55:09
阅读次数:
236
兼具脚本语言,入门更加简单的语言
更加偏向人性化(英文)的编程语言
从2010年开始由克里斯负责开发,前期以GCC编译器为主,后期采用LLVM 6.0
OC诞生于1983年
Swift特点:兼容C Objective-C语言,安全高效并且交互性好,学习曲线平缓
可以不显示指定类型而编译器可以通过赋值来判断变量的类型.但是不支持隐式类型转换,即两种不同类型的变量之间不可以进行运算/赋值...
分类:
其他好文 时间:
2014-07-01 06:42:49
阅读次数:
235
import Foundation
println("Hello, World!")
var string1 = "Hello BeiJing" //定义一个变量(字符串)
//var string1: String = "Hello, BeiJing" //系统会自动进行类型推断为此表达式
println("string1 = \(string1)")
let string2 = "Hel...
分类:
其他好文 时间:
2014-07-01 06:14:53
阅读次数:
191
Swift’s API includes many functions and instance methods that reflect its functional programming heritage. A prime example is calledreduce.You can red...
分类:
移动开发 时间:
2014-07-01 00:27:22
阅读次数:
329
Swift 中的方法是与特定类型(类和结构体)相关的函 数。实例方法 隶属于某个特定类型(类或结构体)实例函数。 class Counter{var count = 0funcincrement() {count++}funcincrementBy(amount: Int) {count += amount}func reset() {count = 0}}let counter = Counte...
分类:
其他好文 时间:
2014-06-30 20:22:51
阅读次数:
301
1、Swift,用来判断option是不是nil,相当于OC的 if(option)
if let name = option{
greeting = “if=====“
}else{
greeting = "else==="
}
2、运行switch中匹配到的子句之后,程序会退出switch语句,并不会继续向下运行,所以不需要在每个子句结尾写break。
3、//使用..创建的范围...
分类:
其他好文 时间:
2014-06-30 20:17:41
阅读次数:
225
var ivar = [:]
ivar.className // __NSDictionaryI
var i = 1
i.className // error: 'Int' does not have a member named 'className'
If you want to get the type of a primitive, you have to use brid...
分类:
移动开发 时间:
2014-06-30 20:14:35
阅读次数:
311
swift 下的performSelector的伪装实现。...
分类:
其他好文 时间:
2014-06-30 19:42:49
阅读次数:
248
属性的存储 属性的主要作用是存储数据,可以常量属性和变量属 性;struct FixedLengthRange {
var firstValue: Int let length: Int
}
var rangeOfThreeItems =FixedLengthRange(firstValue: 0,
length: 3)
// the range represents integer value...
分类:
其他好文 时间:
2014-06-30 18:53:33
阅读次数:
271
本人自己录制的swift菜鸟入门,欢迎大家拍砖,有什么问题可以在这里留言。 主要内容: 函数定义与调用(Defining and Calling Functions) 函数参数与返回值(Function Parameters and Return Values) 函数参数名称(Function Parameter Names) 函数类型(Function Types) 函数嵌套(Nested Fu...
分类:
其他好文 时间:
2014-06-30 16:35:58
阅读次数:
235