5

我想观察AVAudioPlayer的“currentTime”属性。但该方法甚至没有被称为...我需要它来设置一个UISlider的位置..但是它不起作用。以下是相关代码:KVO AVAudioPlayer不工作

[audioPlayer addObserver:self forKeyPath:@"currentTime" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil]; 


- (void)observeValueForKeyPath:(NSString *)keyPath 
         ofObject:(id)object 
         change:(NSDictionary *)change 
         context:(void *)context { 
    NSLog(@"%@", change); 
} 

谢谢。

回答

5

我相信currentTime不符合KVO检查标题。

无论如何,您只需以您想要的频率启动NSTimer并以此方式更新您的UI。