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]);

  }