Your "logic" currently is fine, it's the implementation that you have problem with.
If you check the initWithFile
function, you see that it takes a file name as a string.
So you need to make an array of strings (the file names) and not an array of integers. Then you use the random index as index into this file-name array and pass it as argument to the initWithFile
function.