I am a beginner on swift and I have tried to use random but I have this error:
Cannot subscript a value of type '[String]' with an argument of type 'UInt32'
I don't understand why. Here is my code:
import UIKit
class ViewController: UIViewController {
var Person = ["jean Michel" , "antoine roubet" , "samuel demets" , "zater burkov", "Gochnik samuel"]
var city = ["De Paris","De Monreal","Du Maroc","De Tunis","De sarcelles","De roubaix"]
@IBOutlet weak var quoteLabel: UILabel!
@IBAction func changeQuote() {
var randomIndex = arc4random_uniform(UInt32(Person.count))
var thePerson = Person[randomIndex]
print(thePerson)
var randomIndex2 = arc4random_uniform(UInt32(city.count))
var theCity = city[randomIndex2]
print(theCity)
quoteLabel.text = "le texte est modifié"
}
}
Aucun commentaire:
Enregistrer un commentaire