swiftではarcNrandom_uniform(UInt32(hoge.count))でランダムに数値を生成します。
Tips
command + option + 0: utility 非表示
launch screen -> main.storyboardに変更可能
import UIKit class ViewController: UIViewController { @IBOutlet weak var myLabel: UILabel! @IBAction func getOmikuji(sender: AnyObject) { let results = [ "大吉", "吉", "中吉", "凶", "大凶" ] // arc4random_uniform(n + 1) let random = arc4random_uniform(UInt32(results.count)) if random == 0 { self.myLabel.textColor = UIColor.redColor() } else { self.myLabel.textColor = UIColor.blackColor() } self.myLabel.text = results[Int(random)] } 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. } }