Use AVAudioSession to get available inputs. On my iPhone 5 it looks like this.
NSLog(@"%@", [AVAudioSession sharedInstance].availableInputs);
"<AVAudioSessionPortDescription: 0x14554400, type = MicrophoneBuiltIn; name = iPhone Microphone; UID = Built-In Microphone; selectedDataSource = Back>"
Then use one of these inputs to get availableDataSources, like this.
NSLog(@"%@", [AVAudioSession sharedInstance].availableInputs[0].dataSources);
"<AVAudioSessionDataSourceDescription: 0x145afb00, ID = 1835216945; name = Bottom>",
"<AVAudioSessionDataSourceDescription: 0x145b1870, ID = 1835216946; name = Front>",
"<AVAudioSessionDataSourceDescription: 0x145b3650, ID = 1835216947; name = Back>"
Now you can set your preferred data source.
AVAudioSessionPortDescription *port = [AVAudioSession sharedInstance].availableInputs[0];
for (AVAudioSessionDataSourceDescription *source in port.dataSources) {
if ([source.dataSourceName isEqualToString:@"Back"]) {
[port setPreferredDataSource:source error:nil];
}
}