Sharing an Audio File in Swift
How do I share an audio file which exists in my apps document directory to other apps?
To elaborate on this question, what I mean is when a user taps a share button in the app they should be able to email their recorded audio track to another person, or alternatively to be able to send it across to a range of other apps which can handle audio like perhaps soundcloud.
Researching the topic, I have found:
UIActivityViewController
UIDocumentInteractionController
Since my application makes an audio recording of a person's voice which they should be able to share, and despite searching through stack overflow, I have not been able to find a code example of how exactly this option can be implemented in a Swift app. Can I request suggestions and example code on how this may be accomplished. Many Thanks,
My answer is using for doing this with UIDocumentInteractionController.
I begin by instantiating a UIDocumentInteractionController at the top of my class
Then I link up an IBAction to a share button on my nib or Storyboard: