In my app, I have a title and artist that I want to appear randomly on the view controller, here's my relevent code:
var songTitle = ["Happy", "Sad"]
var aristTitle = ["The Happy Band", "The Sad Band"]
override func viewDidLoad() {
super.viewDidLoad()
var random = Int(arc4random_uniform(UInt32(songTitle.count)))
var titleOn = songTitle[random]
titleText.text = titleOn
artistText.text = ???
So, basically, if the title Happy randomly apears, I want the artist to be The Happy Band. But, if I use arc4random for the artist as well, there is a chance that the artist will be The Sad Band. How do I do this? (I'm using Swift 3 and Xcode 8)
Just use the same index for both.
artistText.text = artistTitle[random]