I am listing my audio into a tableView cell with trailing swipe for delete and share button. Here, I have to do two things:
- I need to convert audio data to file
 - Share the file to another application like Gmail, etc.
 
Code:
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
    if editingStyle == .delete {
        if let context = (UIApplication.shared.delegate as? AppDelegate)?.persistentContainer.viewContext {
            let sound = sounds[indexPath.row]
            context.delete(sound)
            getSound()
        }
    }
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    let sound = sounds[indexPath.row]
    if let audioData = sound.audioData {
        audioPlayer = try? AVAudioPlayer(data: audioData)
        audioPlayer?.play()
    }
}