samedi 6 janvier 2018

Swift : A button to return a random number and a random word each time it's clicked?

I'm brand new to programming, and I'm starting with SWIFT.

I'd like to create an app that every time I click a button, it will return a random number, and a random word on screen.

The idea is, when I click a button a random exercise (from a list) and random number of reps (between 1 and 11) would be displayed.

Here is how far I've got, and now I'm stuck. Any help is GREATLY appreciated. Thank you.

PS it would be great I could add a counter to show how many times I've clicked the button and returned an exercise.


import UIKit

class ViewController: UIViewController {

let reps = Int(arc4random_uniform(UInt32(11)))

let exercises = ["Squats", "Pressups", "Situps", "Burpees"]

@IBAction func workoutButton(_ sender: UIButton) {

}

@IBOutlet weak var numberOfReps: UITextField!

@IBOutlet weak var nameOfExercise: UITextField!

}




Aucun commentaire:

Enregistrer un commentaire