- Application Development in iOS 7
- Kyle Begeman
- 187字
- 2021-07-16 11:49:58
NSProgress
iOS 7 introduces a completely new class to the Foundation framework, NSProgress
. Using NSProgress
involves treating each task of an action as a milestone of completion. By doing so, you, the developer, can track progress directly in code and perform individual tasks for each milestone.
For instance, to perform a particular action, you may require four separate tasks to be completed. Each task is capable of monitoring its own progress, and will report once the task is complete. In our example, this would increase the percent of completion to 25.
NSProgress
uses Key Value Observing (KVO) to provide notifications related to progress. These notifications can be used to update a UI component displaying progress to the user, such as a progress bar or label. The following code is a very simple implementation that demonstrates working with NSProgress
to report progress in a localized manner:
NSArray *data = @[@"Data 1", @"Data 2", @"Data 3", @"Data 4"]; self.dataProgress = [NSProgress progressWithTotalUnitCount:data.count]; int index = 0; for (NSString *string in data) { // Do something with string or other data index ++; self.dataProgress.completedUnitCount = index; NSLog(@"%@", [self.dataProgress localizedDescription]); }
- Kubernetes修煉手冊
- 30天自制操作系統(tǒng)
- 構建高可用Linux服務器(第4版)
- Ansible權威指南
- Learning Android Intents
- 無蘋果不生活 OS X Mountain Lion隨身寶典
- 新手易學:系統(tǒng)安裝與重裝
- 精解Windows8
- 嵌入式系統(tǒng)原理及開發(fā)
- Dreamweaver CS5.5 Mobile and Web Development with HTML5,CSS3,and jQuery
- Windows Server 2012網(wǎng)絡操作系統(tǒng)項目教程(第4版)
- Windows 8實戰(zhàn)從入門到精通(超值版)
- 寫給架構師的Linux實踐:設計并實現(xiàn)基于Linux的IT解決方案
- Drupal 7 Cookbook
- 大學計算機應用基礎實踐教程(Windows 7+MS Office 2010)