views:

60

answers:

1

I seem to have a bug because I'm using -[AVAudioSession setActive:withFlags:error:] in an iPhone project that is for 3.0 - 4.0.2. So I guess I need to put one of those #IF lines in, so I can get it to do different things based on the OS version... But I can't find out how to do it.

Can anyone help please? Thanks! :)

+4  A: 

You simply have to check if the method you're trying to call really exists:

if ([AVAudioSession respondsToSelector:@selector(setActive:withFlags:error:)]) {
   // call it
}
Philippe Leybaert
Great! Thanks :)
Joe
Just for the record though, I had to change it to [[AVAudioSession sharedInstance] respondsToSelector: ... etc.
Joe