-3
這個代碼在迅速版1完全正常,但是當我更新,以迅速2.0它給了我一個錯誤:奇怪的雨燕2.0 if/else語句錯誤
import UIKit
class ViewController: UIViewController {
@IBOutlet var inpute: UITextField!
@IBOutlet var output: UILabel!
@IBAction func button(sender: AnyObject) {
print(inpute.text)
let randomnum = arc4random_uniform(6)
let guessblank = Int(inpute.text!)
if guessblank != nil {
if Int(randomnum) == guessblank {
output.text = "you got it correct"
}
else { output.text = "Wrong number"
}
// here is where the error is. It tells me "Expected
// expression" and "missing condition in if statement"
else { output.text = "please input a number"
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
該代碼不會在Swift 1中編譯,所以不要聲稱它做了。 – matt