Nekbeth

Apr 24, 2011, 12:43 PM

Hello, I'm trying to get the Total minutes for a Timer. I already got the seconds working. Here is how I got "Total Seconds":

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents *comps = [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:time];

NSInteger hour = [comps hour];

NSInteger minute = [comps minute];

NSLog(@"Hour:%i", hour);

NSLog(@"minute:%i", minute);

NSInteger secs =hour * 60 * 60 + minute * 60;

NSNumber *elapsedSeconds = [[NSNumber alloc] initWithInt:secs];

NSDictionary *myDict = [NSDictionary dictionaryWithObject:elapsedSeconds forKey:@"TotalSeconds"];

It might be only to change the formula, any help would be much appreciated. Thanks

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSDateComponents *comps = [gregorian components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:time];

NSInteger hour = [comps hour];

NSInteger minute = [comps minute];

NSLog(@"Hour:%i", hour);

NSLog(@"minute:%i", minute);

NSInteger secs =hour * 60 * 60 + minute * 60;

NSNumber *elapsedSeconds = [[NSNumber alloc] initWithInt:secs];

NSDictionary *myDict = [NSDictionary dictionaryWithObject:elapsedSeconds forKey:@"TotalSeconds"];

It might be only to change the formula, any help would be much appreciated. Thanks