title: Playing system sounds using Swift
body: <p>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 <strong>var ref</strong> 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!</p>
  
  <pre><code>        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, &amp;soundID)
          AudioServicesPlaySystemSound(soundID)
  </code></pre>