samedi 16 mai 2020

How to use Int.random(in: ) when the max index value isn't known [duplicate]

Lets say I wanna create a button that displays a random Item inside an array by using the method Int.random(in: )What do I do if I don't know how many items I have in my Array (i.ex the max index value is unknown). For example if I were to handle user input and I don't know how many items the user has added?

I couldn't find another thread which was dedicated to this problem when it comes to Swift or being asked in a clear way without anecdotal examples from a specific project being included




Aucun commentaire:

Enregistrer un commentaire