Is there a method to close files in Swift? Specifically AVAudioFile files?

I have no problem creating, and writing to AVAudioFiles.

do {
   audioFile = try AVAudioFile(forWriting: destinationPath, settings: format.settings)
   print ("created: \(curFileLinkName)")
} catch { print ("error creating file")}

But is there a way to close the file?

I've searched and all I could find was this very post on StackOverflow, which makes me wonder.

Answered by DTS Engineer in 721119022

Hello,

There is not, the file closes once the AVAudioFile is deinitialized. I recommend that you file an enhancement request for this functionality using Feedback Assistant, and provide a short description about how this functionality would benefit your app.

Accepted Answer

Hello,

There is not, the file closes once the AVAudioFile is deinitialized. I recommend that you file an enhancement request for this functionality using Feedback Assistant, and provide a short description about how this functionality would benefit your app.

There is not, the file closes once the AVAudioFile is deinitialized

if I use the same handle to create a second file, would that close the first?

Is there a method to close files in Swift? Specifically AVAudioFile files?
 
 
Q