I'm playing around in Objective-C with a "foundation tool" (Objective-C command line utility) project in Xcode. At the end of my program, it's supposed to go to a clock that updates itself in the Terminal window. The problem is that it doesn't start on the right time, so it's almost always off by a fraction of a second. I tried to fix that by having it wait until the nanosecond time is a multiple of 10^9, but this ends up just going into infinite loop. What am I doing wrong, and is there a better way (I'm guessing there is)?