Swift Language Need fix code please. I have the follow code. I trying to get an
ID: 669707 • Letter: S
Question
Swift Language Need fix code please.
I have the follow code. I trying to get an array of int that are random using the random fuction below.
Errors: Variable self.imageNumbers passed by reference before being initalized
Return from intializer without initializing all stored properties.
import UIKit
public class MediaManger{
private var imageNumbers:[Int]
public init()
{
//Trying to get array of 25 random numbers in a array
for i in 1...25
}
//Random
srand(UIn32(time(nil)))
var rand_num = Int(rand()%25) + 1
imageNumbers.append(rand_num)
}
}
}
Explanation / Answer
You need to initialize selfNumbers
private var imageNumbers:[Int] = []
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.