tags:

views:

406

answers:

2

Hello all,

I'm using SCListener to get the iPhone's volume, but I'd like to put an observer on the volume. So when it changes I can update the volume meter on the screen. But doing something like:

SCListener *listener = [SCListener sharedListener];
[listener addObserver:self 
           forKeyPath:@"peakPower" 
              options:NSKeyValueObservingOptionOld 
              context:NULL];

doesn't do the trick because peakPower isn't a variable. How would I put an observer on the function? Or how would a create a listener I could stop and start to keep track of the peak power in a variable I could put an observer on?

Thanks in advance for the help!

A: 

SCListener is not Key Value Observer compliant. AFAIK, you have to poll for the values.

Roger Nolan
Thanks for the answer Roger!How would I go about polling the values for a class like SCListener?
A: 

Simply set up a repeating timer, and read the levels each time the timer fires.

Simon