Search code examples
iosjsonavaudiorecorder

convert AVAudioRecorder to NSString or bytes


I am trying to send AVAudioRecorder in Json , i would like to convert it to NSString or Byte.. any idea?


Solution

  • Never tried but maybe this ?

    // Get the recording
    AVAudioRecorder *recorder = [[AVAudioRecorder alloc] initWithURL:filePath settings:recordSetting error:&error];
    ....
    // Convert to NSData
    NSData *theData = [[NSData alloc] initWithContentsOfFile:filePath];
    // Convert to NSString
    NSString* dataAsString = [NSString stringWithUTF8String:[theData bytes]];