0

I am new to iphone development, I am developing an application, which takes restaurant order data (Name of Restaurant and order price) and save to an array and display on another UITable, but now I want to start a timer such as

Royal Taj

$35

1 hour, 40 mints remaining,

so how can I count such time, on different orders, I need a little guide regarding it, and time should go in decrement, not increment ,,,,

if you are not clear about my question, then u can ask me anything again....

Chatar Veer Suthar
  • 15,541
  • 26
  • 90
  • 154

1 Answers1

0

here is what i have done and its working ...........

{

NSDictionary* temp = [allOrder objectAtIndex:indexPath.row];
NSDate* dt = (NSDate*)[temp objectForKey:@"date"];
NSTimeInterval inter = [dt timeIntervalSinceNow];
int hour = inter / 3600;
int min = ((long)inter % 3600)/60;
NSString* str;
if (hour == 0) 
{
    if (min == 0) 
        str = [NSString stringWithFormat:@"Order is ready to serve"];
    else
        str = [NSString stringWithFormat:@"%d minutes remaining",min];
}
else {
    if (min == 0) 
        str = [NSString stringWithFormat:@"%d hours remaining",hour];
    else
        str = [NSString stringWithFormat:@"%d hours and %d minutes remaining",hour,min];
}
cell.detailTextLabel.text = str;

}

here i supposed that u have an array allOrder which contains dictionaries which has object for keys @"date" as the date on which order has to be delivered.

Amit Singh
  • 8,383
  • 4
  • 28
  • 31