Motivation: I\'m working on an app that makes several (client) phones read audio data from a (server) phone. The idea is that they must all play th
It turns out it's simpler than I thought (note: getCurTime is defined in the question):
-(void)performAction
{
double curTime = [Timer getCurTime];
double timeInFuture = 2 + curTime;
NSLog(@"this is time in future in abs terms %f and this is curTime %f",timeInFuture, curTime);
CFDateRef futureDate = CFDateCreate(NULL, timeInFuture);
CFDateRef dateNow = CFDateCreate(NULL, curTime);
Boolean keepTesting = true;
while (keepTesting) {
dateNow = CFDateCreate(NULL, [Timer getCurTime]);
if (CFDateCompare(dateNow, futureDate,NULL) >= 0) // ie both times are equal or we've
// gone past the future date time
{
NSLog(@"now is the time!");
keepTesting = false;
return;
} else {
NSLog(@"now isn't the time.. skip");
}
}
}