-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
AVAudioSession *currentSystemVolume = [AVAudioSession sharedInstance];
if ([keyPath isEqual:@"outputVolume"]) {
if([[AVAudioSession sharedInstance] outputVolume] < currentSystemVolume.outputVolume)
{
NSLog(@"Volume key down");
//your code when volume key down is pressed.
} else if([[AVAudioSession sharedInstance] outputVolume] > currentSystemVolume.outputVolume)
{
NSLog(@"Volume key up");
//your code when volume key up is pressed.
}
}
}
Unfortunately you're testing the changed volume against the current volume which is the changed volume - so they're equal, no?