Import the above 2 frames #import <AVFoundation/AVFoundation.h> #import <corefoundation/corefoundation.h>// Declaration of the following 4 attributes @property (nonatomic, assign) BOOL recording; Determine if you can record @property (nonatomic, strong) NSString *filename; The audio file is stored with the file name @property (nonatomic, strong) Avaudiorecorder *recorder; Declare a Recorder @property (nonatomic, strong) Avaudioplayer *player; Declares an audio player-(void) startrecording{if (self.recording) {return; } self.recording =yes;//set the recording format avformatidkey==kaudioformatlinearpcm//set the recording sample rate (HZ) such as: avsampleratekey==8000/44100 /96000 (affects the quality of audio)//Recording channels 1 or 2 avnumberofchannelskey//linear sample digits 8, 16, 24, avlinearpcmbitdepthkey//recording quality A Vencoderaudioqualitykey = = avaudioqualityhigh//Avlinearpcmisbigendiankey big or small end, is the way of memory Organization//Avlinearpcmisfloatkey Mining The sample signal is an integer or floating-point number nsdictionary *audiosettingdict =[nsdictionary dictionarywithobjectsandkeys: [NSN Umber Numberwithfloat:8000],avsampleratekey, [NSNumber numberwITHINT:KAUDIOFORMATLINEARPCM], Avformatidkey, [NSNumber Numberwi Thint:1],avnumberofchannelskey, [NSNumber Numberwithint:16],avlinearpcmbitdepthkey, [NSNumber Numberwithbool:no],avlinearpcmisbigendiankey, [NSNumber Numberwithboo L:no],avlinearpcmisfloatkey, [NSNumber Numberwithint:avaudioqualityhigh],avencoderaudioqualityk EY, nil]; Nserror *error =nil; Avaudiosession * audiosession = [avaudiosession sharedinstance]; [Audiosession Setcategory:avaudiosessioncategoryplayandrecord error:&error];//Sets the audio category, which means that when the app starts, the background other audio is stopped [ Audiosession Setactive:yes error:&error];//Set current app audio active nsdate *now =[nsdate Date]; Instantiate a NSDateFormatter object nsdateformatter *dateformater = [[NSDateFormatter alloc] init]; Set the time format, where you can set the format you want [Dateformater setdateformat:@ "Yyyy-mm-dd hh-Mm-ss "]; NSString *filename = [NSString stringwithformat:@ "Rec_%@.wav", [Dateformater Stringfromdate:now]]; Self.filename =filename; NSString *filepath =[nsstring Documentpathwith:filename]; Nsurl *fileurl =[nsurl Urlwithstring:filepath]; Initialize the recorded class Self.recorder =[[avaudiorecorder alloc]initwithurl:fileurl settings:audiosettingdict error:&error]; [Self.recorder Preparetorecord]; [Self.recorder peakpowerforchannel:0]; [Self.recorder Setmeteringenabled:yes]; [Self.recorder record];}