Simple audio recording using Swift

Just a quick post on how to get audio recording happening on iOS using Swift.

All you need to do is copy this into your UIViewController.

The code itself is quite self explanatory. Make sure at the top of your class to include the line, “import AVFoundation”, this contains the libraries necessary to interact with the audio file system on iOS.

toggleRecording() – The function to call to toggle your audio recording on/off. You’ll need to setup a button linking to this function.

That’s it. Playing the file back is also quite straight forward, but I’ll include that in a later post.

 

Leave a comment