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 += am...
分类:
其他好文 时间:
2014-06-30 23:26:49
阅读次数:
225
还记得字典吗?[html]view plaincopyvarnumberOfLegs=["spider":8,"ant":6,"cat":4]numberOfLegs["bird"]=2["bird"]就是下标 下标可以在类和结构体中定义。定义下标[html]view plaincopysubscr...
分类:
其他好文 时间:
2014-06-30 21:59:22
阅读次数:
271
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