On 11 Dec 2008, at 11:03 am, Chunk 1978 wrote:

i believe i painted myself into a corner here... i have a
NSPopUpButton with 3 items.  1 Hour, 2 Hours, 3 Hours.  each item has
respected tag numbers 1, 2 and 3.  i'm attempting to print out time
remaining but i can only get as far as displaying seconds remaining
with this:  NSLog(@"%.2d Seconds Remaining", (hoursSelected -
second));  but i would like for the log to output @"%.2d Hours, %.2d
Minutes and %2d Seconds Remaining";  i can't wrap my head around it,
and i fear that my trying to be as if/else statementless as possible
by using the tag numbers of the PopUp Menu is causing me problems.



warning: typed into mail, off the top of my head:


int hours, minutes, seconds, totalSecondsRemaining;


totalSecondsRemaining = ( menuValue * 3600 ) - timeElapsedSoFar;

hours = totalSecondsRemaining % 3600;
totalSecondsRemaining -= ( hours * 3600 );
minutes = totalSecondsRemaining % 60;
totalSecondsRemaining -= ( minutes * 60 );
seconds = totalSecondsRemaining;

NSLog(@"remaining time: %.2d hours, %.2d minutes, %.2d seconds", hours, minutes, seconds );


n.b the key is to use the mod operator (%). I believe in some schools modulo arithmetic is called "clock arithmetic".

hth,

Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to