摘要: 在前面, 我们知道了Swift中的Protocol和Extensions, 现在我们来看看另一个东西: Generics(泛型)1.泛型的声明以及简单使用func repeat (item:ItemType, times:Int) -> [ItemType] { var re... 阅读全文
posted @ 2015-03-10 18:43 背着吉他去流浪 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 前面我们知道了枚举类型和结构体的声明, 嵌套, 以及基本的使用, 现在让我们来看看Swift中的另外两个, 一个是Protocol(协议), 一个是Extensions(类别):1.声明Protocolprotocol ExampleProtocol{ var simpleDe... 阅读全文
posted @ 2015-03-10 17:12 背着吉他去流浪 阅读(366) 评论(0) 推荐(0) 编辑
摘要: 在Siwft中的枚举类型以及结构体, 是和OC中差不多的, 但Swift中又有一些特性, 下面让我们来看看:1.枚举的声明及使用enum Rank: Int { case Ace = 1 case Two, Three, Four, Five, Six, Seven, E... 阅读全文
posted @ 2015-03-10 16:34 背着吉他去流浪 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 在前面我们讲解完了一些基本的东西, 现在来看看Swift里面的类声明已经怎么使用对象.1.类方法class Shape { var numberOfSides = 0 func simpleDescription() -> String{ return "A... 阅读全文
posted @ 2015-03-10 12:05 背着吉他去流浪 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 在Swift中, 一样是存在函数和闭包的, 现在让我们来看看Swift的函数和闭包:1.使用func来声明函数func person(name: String, age:String) -> String { return ("The name is \(name), ... 阅读全文
posted @ 2015-03-10 09:44 背着吉他去流浪 阅读(168) 评论(0) 推荐(0) 编辑