This code works perfectly fine in swift version 1, however when I updated to swift 2.0 it gives me an error:
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.
}
}
Aucun commentaire:
Enregistrer un commentaire