samedi 12 juin 2021

How can I add text to a label from two different arrays in swift chosen at Random

So at the moment I have created a label with a frame on the screen which displays the chosen text. I also have two different arrays for the first and last name.

let nameArray = ["Jacob", "Lenny", "George", "Linda", "Arthur"] let lastNameArray = ["Shelby", "Knight", "Luiz", "Hamilton", "Dobson"]

when I use nameLabel.text = nameArray.randomElement() it works fine but I want it to display both, a random first name and a random last name from the given arrays within the same label. How would I go about doing this?




Aucun commentaire:

Enregistrer un commentaire