dimanche 31 janvier 2016

Check the value of a constant in Swift

So I'm coding my first app, yeah, from scratch and I never done anything like it before so please bear with me. I wanna take the randomised value of the first constant and use it to determine the content shown on screen through a label upon a view controller, this might be quite easy for some people but I am really struggling here. I commented out my code so you know what i intend it to do. Now, I know I could approach this many different ways such as not having a label at all and photoshop phrases on images but nah.... I wanna CODE!

Any ideas? Thank you all very much :3 <3

import UIKit

class ViewController: UIViewController {
    let random = Int(arc4random_uniform(11)) //Randomised int values from 0 to 11 (-1)
    @IBOutlet weak var text: UILabel!
    @IBOutlet weak var phrase: UIButton! //this button should reset the entire process over again
    @IBOutlet var imageauthor: UIImageView!
    override func viewDidLoad() {
            super.viewDidLoad()
        self .imageauthor.image = UIImage(named:"0\(random).jpg") //Viewcontroller displays a random image out of randomised value
        self .text.text = ("''") //this should somehow check what the randomised value is and call the Uilabel text bellow it
    }


    var string1 = ("My fist app has many holes1")
    ... string2 = ("My fist app has many holes2")
    ... string3.... 




Aucun commentaire:

Enregistrer un commentaire