Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///// CODE FOR TOTAL TIMER //////
- // We get the current time and then use that to calculate the elapsed time.
- NSTimeInterval currentTimeTotal = [NSDate timeIntervalSinceReferenceDate];
- NSTimeInterval elapsedTimeTotal = currentTimeTotal - timeTotal;
- // We calculate the minutes.
- minutesTotal = (int)(elapsedTimeTotal / 60.0);
- // We calculate the seconds.
- secondsTotal = (int)(elapsedTimeTotal = elapsedTimeTotal - (minutesTotal * 60));
- // We calculate the milliseconds.
- millisecondsTotal = (int)((elapsedTimeTotal - (double)secondsTotal) * 1000.0);
- // We update our Label with the current time.
- self.labelTop.text = [NSString stringWithFormat:@"%02u:%02u.%03u", minutesTotal, secondsTotal, millisecondsTotal];
- NSMutableArray *laps; //Array to store the lap times.
- // Display Array of laps within tableview.
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return [laps count];
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *simpleTableIdentifier = @"SimpleTableCell";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
- if (cell == nil) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
- }
- cell.imageView.image = [UIImage imageNamed:@"flag.png"];
- cell.textLabel.text = [NSString stringWithFormat:@"Lap %d", indexPath.row + 1];
- cell.detailTextLabel.text = [NSString stringWithFormat:@"-%02d:%02d.%04d", minutesTotal, secondsTotal, millisecondsTotal];
- //cell.detailTextLabel.text = [NSString stringWithFormat:@"-%02d:%02d.%04d",[laps objectAtIndex:indexPath.row]];
- return cell;
- {
- [laps removeAllObjects];
- laps=[[NSMutablearray alloc]init];
- }
- self.labelTop.text = [NSString stringWithFormat:@"%02u:%02u.%03u", minutesLap, secondsLap, millisecondsLap];
- [laps addobject:self.labelTop.text];
- cell.detailTextLabel.text = [NSString stringWithFormat:@"-%02d:%02d.%04d",[laps objectAtIndex:indexPath.row]];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement