I have some existing code which uses the AVAudioEngine to take input from the microphone, downsample it and write it to a AVAudioFile
AVAudioEngine
AVAudioFile