Swift 5.0
let userInput = "18"
var age = Int(userInput)
if age != nil {
print("Your age is + \(String(describing: age!))")
}
let userInput = "18"
var age = Int(userInput)
if age != nil {
print("Your age is + \(String(describing: age!))")
}
2019-08-15
蘋(píng)果開(kāi)發(fā)者account低價(jià)處理了,需要聯(lián)系:3347675201
2019-05-16
2017年后新版Swift有部分修改:
let lbl = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 100));
let btn = UIButton(frame: CGRect(x: 100, y: 100, width: 200, height: 80));
btn.setTitleColor(UIColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1.0), for: .normal);
btn.setTitle("Click me!", for: .normal);
let lbl = UILabel(frame: CGRect(x: 0, y: 0, width: 300, height: 100));
let btn = UIButton(frame: CGRect(x: 100, y: 100, width: 200, height: 80));
btn.setTitleColor(UIColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1.0), for: .normal);
btn.setTitle("Click me!", for: .normal);
2019-05-12
感覺(jué)swift太太花里胡哨了,在語(yǔ)法上。 初學(xué)的話,很多語(yǔ)法問(wèn)題反而讓人不能更專心于邏輯。
2019-04-18
棄用++和--
// 反向循環(huán)
for i in (0 ... 10).reversed() {
print(i)
}
for i in (0 ..< 10).reversed() {
print(i)
}
// 反向循環(huán)
for i in (0 ... 10).reversed() {
print(i)
}
for i in (0 ..< 10).reversed() {
print(i)
}
2018-03-28
這里的在新版本中,有一個(gè) let num_b:Int = 1.2 就報(bào)錯(cuò)了, 不再是把小數(shù)截掉了
2018-03-28