在使用AVAssetExportSession的
exportAsynchronouslyWithCompletionHandler接口时有个progress属性,打算用KVO去实现监听
static void *ExportProcess = &ExportProcess;
[_exporter addObserver:self forKeyPath:@"progress" options:NSKeyValueObservingOptionNew context:ExportProcess];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context{
if (context == ExportProcess) {
CGFloat process = [change[NSKeyValueChangeNewKey] floatValue];
CGFloat oldProcess = [change[NSKeyValueChangeOldKey] floatValue];
NSLog(@"the process is %f", process);
NSLog(@"the oldProcess is %f", oldProcess);
}
}
但是突然发现
This property is not key-value observable 这个
process不支持 KVO 那只能用定时器监听了或者RCA