I'm trying to play a sound when a button is pressed using system sounds. I keep getting the error: "fatal error: unexpectedly found nil while unwrapping an Optional value". I tried debugging, and I believe the error is occurring on the var ref line. "roar.aif" is a custom sound I have included in my project. It is only a second and a half long. I would appreciate suggestions. Thanks!
var soundID: SystemSoundID = SystemSoundID()
var mainBundle: CFBundleRef = CFBundleGetMainBundle()
var ref: CFURLRef = CFBundleCopyResourceURL(mainBundle, "roar.aif", nil, nil) as CFURLRef!
println("Here is your ref: \(ref)")
AudioServicesCreateSystemSoundID(ref, &soundID)
AudioServicesPlaySystemSound(soundID)