greetings , I'm a cocoa beginner and this is my first post:P
I'm trying to make a very simple rhythm game but get stuck , here's what I got:
/**** TouchView.h/m ****/
@property AVAudioPlayer *audioPlayer;
[self addObserver:self
forKeyPath:@"audioPlayer.currentTime"
options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
context:NULL];
//audioPlayer.currentTime's type is NSTimeinterval (double)
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change (NSDictionary *)change context:(void *)context
{
NSLog(@"action triggered!")
}
which doesn't work (I have initialized audioPlayer properly,it can play sound but just can't be caught when its currentTime value changes)
I test these code with another property "double testNumber" , set it as the argument of "keyPath" , increase it by one when I touch the screen , then that works well. But what should I do to make audioPlayer.currentTime can be observed , I just want to get notified when this value changed , any other advice will also be appreciated. I'm counting on you , please help me ,thanks :)