在使用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
本文探讨了在iOS开发中使用AVAssetExportSession导出视频时如何监测导出进度的问题。作者尝试通过KVO(键值观察)监听progress属性但发现该属性不支持KVO,最终考虑采用定时器或其他方式来解决。
2364

被折叠的 条评论
为什么被折叠?



