i have this code:
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func geraNumeros(_ sender: Any) {
var numeroAleatorio:[Int] = []
for _ in 1...6 {
numeroAleatorio.append(Int(arc4random_uniform(60)+1))
}
numeroAleatorio.sort()
labelNumeros.text = "\(numeroAleatorio[0]) - \(numeroAleatorio[1]) - \(numeroAleatorio[2]) - \(numeroAleatorio[3]) - \(numeroAleatorio[4]) - \(numeroAleatorio[5]) "
}
@IBOutlet weak var labelNumeros: UILabel!
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
But sometimes numbers repeating, like:
10 - 18 - 12 - 10 - 30 - 60
Like 10-10, so what to do?
Aucun commentaire:
Enregistrer un commentaire