-
可變字符串查看全部
-
區間運算符查看全部
-
新增比較運算符查看全部
-
swift 運算查看全部
-
1.Optionals表示可以有值,可以沒值,沒有值就是nil 2.swift中基本數據類型可以為nil,oc就不可以 3. var a:Int 會報錯,因為沒有初始化,除非加上可選, var a:Int ? 4.let userInput = "abc" var age = userInput.toInt(), userInput.toInt()返回int?,用戶輸入的可能是字符串,也可能是數字,因此age可能是int,可能是 nil 5.String(age)類型轉換時,被轉換的不能是可選型,否則報錯。String(age!)要解包 6.可選型很多方法都不能調用,所以要解包查看全部
-
函數:參數如果是可選,則傳進去的也要可選。(name ?? "Guest") 的意思是,看name有沒有值,有就用name ,沒有就用 Guest查看全部
-
yuanzu查看全部
-
Set 的初始化方法以及調用。查看全部
-
數據類型 Int Double String查看全部
-
枚舉規定類型后的rawValue調用,注意這里涉及到可選型的一個概念查看全部
-
閉包作為函數調用的最后一個參數時可以寫在括號外面?好像是這個意思,往后使用時候需要注意這點查看全部
-
太抽象,不過可以mark一下查看全部
-
arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0] arr = arr.sorted { ( a:Int, b:Int) -> Bool in return a > b} arr arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0] arr = arr.sorted { a, b in return a > b} arr arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0] arr = arr.sorted { a, b in a > b} arr arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0] arr = arr.sorted { $0 > $1 } arr arr = arr.sorted(by: >) arr查看全部
-
var backView = UIView(frame : CGRectMake(0.0, 0.0, 320.0, CGFloat(colors.count * 50))) backView.backgroundColor = UIColor.blackColor() backView var indexP = 0 for (colorName,rgbTuple) in colors { // var colorStripe = UILabel(frame:CGRectMake(0, CGFloat(index*50 + 5), 320.0, 40.0)) // index ++ var colorStripe = UILabel(frame : CGRectMake(0.0, CGFloat(indexP*50 + 5), 320.0, 40.0)) // colorStripe.text! = colorName colorStripe.text = colorName colorStripe.textAlignment = NSTextAlignment.Center colorStripe.backgroundColor = UIColor(red: CGFloat(rgbTuple.red/255.0), green: CGFloat(rgbTuple.green/255.0), blue: CGFloat(rgbTuple.blue/255.0), alpha: 1.0) indexP += 1 backView.addSubview(colorStripe) } backView查看全部
-
計算字符數量查看全部
舉報
0/150
提交
取消