简体   繁体   中英

How to record audio and get it as NSData in iOS?

I want to record some thing in my app and post it to some API. Please help

You can follow this link for recording and saving audio in local iPhone storage (ex: Document Directory).

Record audio file and save locally on iPhone

Once you saved it you can convert file content as NSData

NSDate *audioData = [NSData dataWithContentsOfFile:audioFilePath];
// audioFilePath is the path of audio either from document 
// directory or any other location.

This simple tutorial might help you

https://www.appcoda.com/ios-avfoundation-framework-tutorial/

Once you are done recording then you have to choose do you want

 AFNetworking or NSURLConnection 

to send the audio to the server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM