NSProgress

Adding child progress for multiple file download

时间秒杀一切 提交于 2019-12-10 23:04:15
问题 I'm downloading multiple files using AFNetworking 3.0 in my project. I want to show single download progress of all files. I added each child progress of each file download to the parent progress. But it's not working, app crashed. I'm getting the error - Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<DownloadManager: 0x7f92e2f6e130>: An -observeValueForKeyPath:ofObject:change:context: message was received but not handled. Key path: fractionCompleted

iOS进度指示器——NSProgress

喜欢而已 提交于 2019-12-05 23:55:29
iOS进度指示器——NSProgress 一、引言 在iOS7之前,系统一直没有提供一个完整的框架来描述任务进度相关的功能。这使得在开发中进行耗时任务进度的监听将什么麻烦,在iOS7之后,系统提供了NSProgress类来专门报告任务进度。 二、创建单任务进度监听器 单任务进度的监听是NSProgress最简单的一种运用场景,我们来用定时器模拟一个耗时任务,示例代码如下: @interface ViewController () { NSProgress * progress; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //这个方法将创建任务进度管理对象 UnitCount是一个基于UI上的完整任务的单元数 progress = [NSProgress progressWithTotalUnitCount:10]; NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(task)