Record Audio in iPhone.

You need to add CoreAudio.framework to implement recording.
Also import following headers in .h file


declare below in .h file itself      
       AVAudioRecorder * recorder;
	NSError * error;
       NSURL * recordedTmpFile;

Now add the following function in .m file to startRecording

	//Record setting in MutableArray
	NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
	[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
	[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
	[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
	//Now that we have our settings we are going to instanciate an instance of our recorder instance.
	//Generate a temp file for use by the recording.
	recordedTmpFile = [NSURL fileURLWithPath:
					   [NSTemporaryDirectory() stringByAppendingPathComponent: 
						[NSString stringWithFormat:
						 @"Myrecording%d.%@",i++, @"caf"]]];
	NSLog(@"Using File called: %@",recordedTmpFile);
	//Setup the recorder to use this file and record to it.
	recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
	//Use the recorder to start the recording.
	[recorder setDelegate:self];
	//We call this to start the recording process and initialize 
	[recorder prepareToRecord];
	//Start the actual Recording
	[recorder record];

To stop the recording and play add following function

       [recorder stop];
       AVAudioPlayer * avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordedTmpFile error:&error];
	[avPlayer prepareToPlay];
	[avPlayer play];

There is an optional method for doing the recording for a limited time see :

	[recorder recordForDuration:(NSTimeInterval) 10];