jeudi 6 août 2015

Swift: random depends from time on device

I am novice programmer =) Help me please with random generator. How to make the generation of a random choice depends by the time on the device?

func randomteTxt() {

    var arr_person = [String]();
    arr_person.append("ГЕНЕРАЛ");
    arr_person.append("С КОЛБОЙ");
    arr_person.append("ШПИОН");
    arr_person.append("АРХИМЕД");
    arr_person.append("ШЕКСПИР");
    arr_person.append("С ФОНАРЕМ");
    arr_person.append("БАРОН");
    arr_person.append("ДИПЛОМАТ");

    greatperson.text = arr_person[Int( random()%(arr_person.count))];




Aucun commentaire:

Enregistrer un commentaire