I am currently making an App for my grandson who has been diagnosed with Autism. One of the games I am putting on the app is a simple flash card game. Hit the button it produces a random image with a letter. I want add sound to the random image. example if image A appears the sound for letter A happens. I know how to add the sound to a file, just not sure how to figure out how to get the sound to match the random image. Here is my code. Any help greatly appreciated.
import UIKit
import AVFoundation
class Say_It_VC: UIViewController {
@IBOutlet var imageOne: UIImageView!
let imageNames = ["A3","B3","C3","D3","E3","F3","G3","H3","I3","J3","K3","L3","M3","N3","O3","P3","Q3","R3","S3","T3","U3","V3","W3","X3","Y3","Z3"]
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func showImages(_ sender: Any) {
let leftNumber:Int = Int (arc4random_uniform(26))
imageOne.image = UIImage (named: imageNames[leftNumber])
}
}