How to shuffle an array in Swift? Detailed guide
Hello everyone! I'm new to Swift and writing a simple iOS app — a quiz. I have an array of questions, and I want the questions to appear in random order each time the game starts. I've tried several methods, but nothing works as expected.
Here's my code:
```swift
var questions = ["Question 1", "Question 2", "Question 3", "Question 4", "Question 5"]
// My attempt to write my own shuffle function
func myShuffle(array: [String]) -> [String] {
var newArray = array
for i in 0..
No answers yet.
Log in to leave an answer