- 博客(7)
- 收藏
- 关注
转载 swift 泛型
下面是一个泛型的函数func SwapTwoValues (inout a: T,inout b :T){ let tempValue = a a = b b = tempValue}这个函数主体、功能跟上面的例子类似,用来交换两个同样类型的值,但是这个函数用 T 占位符来代替实际的类型。并没有指定具体的类型,但是传入的a ,b 必须是同一类型T。在调用这个函
2016-08-30 17:14:02 229
原创 Swift 单例
代码如下class GameManager: NSObject { var score = 0 static let defaultManager = GameManager() private override init() { } func addScore() { score
2016-08-26 17:00:32 348
原创 Swift 枚举
代码如下enum ConnectServerStatus { case success(String) case error(Int) case waiting case lostConnect}func connect(status:Int?) -> ConnectServerStatus { if let status = status {
2016-08-25 10:04:33 239
原创 Swift 闭包
代码如下 var numArray:[Int] = [];for _ in 0 ... 100 { numArray.append(random() % 1000)}numArray.sort({(a:Int , b:Int) -> Bool in return a > b})
2016-08-24 14:19:35 184
原创 Swift 函数型参数
就是把函数名当参数代码如下:var numArray:[Int] = [];for _ in 0 ... 100 { numArray.append(random() % 1000)}func biggerNumberFrist(a:Int , b:Int) -> Bool { if a > b { return true } ret
2016-08-24 11:44:37 207
原创 swift 变长参数
func getMean(value:Double ...) -> Double { var all:Double = 0 // 把变长参数当数组使用 for num in value { all += num } return all / Double(value.count)}getMean(1,2,3,4,5,6,54)getM
2016-08-23 18:36:00 659
原创 ios调用淘宝
宝贝详情 taobao://item.taobao.com/item.htm?id=12688928896宝贝搜索 taobao://s.taobao.com/?q=iphone
2016-08-08 18:19:25 387
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人