Yes, I am trying to write an IOS app in Swift. It compiles and runs without any warnings or errors. My main goal is for the contents of the array to briefly show onto the label right before the random element that was selected is displayed. Pretty much like a randomizer does right before displaying the random element. The whole functions is:
var prev = -1
@IBAction func Random()
{
let Places = ["Burger King","Chick-Fil-A","McDonald's","Wendys","Checkers","TacoBell","PDQ","Pizza Hut","Jimmy John's","Subway","Dominos","Pollo Tropical","Chipotle","Olive Garden","Ale House","Five Guys","Fresh Kitchen","Blaze","Outback"]
label.isHidden = false
var i = 0
var number = Int.random(in: 0..<19)
if(prev == number)
{
number = Int.random(in: 0..<19)
}
while i<Places.count
{
label.text = Places[i]
sleep(UInt32(0.99))
i+=1
}
label.text = Places[number]
prev = number
}
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: