title: How to work a button at the same time in Xcode?
body: <p>I want to make an application like Noisli website.For example when i tapped rain, it will play but when i press thunder sound it will play to and close the sound with tap again.But it works separately.</p>
  
  <p>I have a function for tap button</p>
  
  <pre><code>@IBAction func buttonTapped(_ sender: UIButton) {
  
      let tag = sender.tag
      PlaySound(filename: sounds[tag])
  
  }
  
  func PlaySound(filename:String){
  
      let url = Bundle.main.url(forResource: filename, withExtension: "mp3")
  
              guard url != nil else{ //url not empty
                  return
              }
  
              do{
                 audioPlayer = try AVAudioPlayer(contentsOf: url!)
                  audioPlayer?.play()
              }
              catch{
                  print("error")
              }
  
  }
  </code></pre>