Advertisement
Guest User

Untitled

a guest
Apr 17th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. ///// CODE FOR TOTAL TIMER //////
  2. // We get the current time and then use that to calculate the elapsed time.
  3. NSTimeInterval currentTimeTotal = [NSDate timeIntervalSinceReferenceDate];
  4. NSTimeInterval elapsedTimeTotal = currentTimeTotal - timeTotal;
  5. // We calculate the minutes.
  6. minutesTotal = (int)(elapsedTimeTotal / 60.0);
  7. // We calculate the seconds.
  8. secondsTotal = (int)(elapsedTimeTotal = elapsedTimeTotal - (minutesTotal * 60));
  9. // We calculate the milliseconds.
  10. millisecondsTotal = (int)((elapsedTimeTotal - (double)secondsTotal) * 1000.0);
  11. // We update our Label with the current time.
  12. self.labelTop.text = [NSString stringWithFormat:@"%02u:%02u.%03u", minutesTotal, secondsTotal, millisecondsTotal];
  13.  
  14. NSMutableArray *laps; //Array to store the lap times.
  15.  
  16. // Display Array of laps within tableview.
  17. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  18. {
  19. return [laps count];
  20. }
  21.  
  22. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  23. {
  24. static NSString *simpleTableIdentifier = @"SimpleTableCell";
  25.  
  26. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
  27.  
  28. if (cell == nil) {
  29. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
  30. }
  31.  
  32. cell.imageView.image = [UIImage imageNamed:@"flag.png"];
  33. cell.textLabel.text = [NSString stringWithFormat:@"Lap %d", indexPath.row + 1];
  34. cell.detailTextLabel.text = [NSString stringWithFormat:@"-%02d:%02d.%04d", minutesTotal, secondsTotal, millisecondsTotal];
  35. //cell.detailTextLabel.text = [NSString stringWithFormat:@"-%02d:%02d.%04d",[laps objectAtIndex:indexPath.row]];
  36.  
  37.  
  38. return cell;
  39.  
  40. {
  41. [laps removeAllObjects];
  42. laps=[[NSMutablearray alloc]init];
  43. }
  44.  
  45. self.labelTop.text = [NSString stringWithFormat:@"%02u:%02u.%03u", minutesLap, secondsLap, millisecondsLap];
  46. [laps addobject:self.labelTop.text];
  47.  
  48. cell.detailTextLabel.text = [NSString stringWithFormat:@"-%02d:%02d.%04d",[laps objectAtIndex:indexPath.row]];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement