If I have:
double now_ms() {
return 1000 * (float)[[NSDate date] timeIntervalSince1970];
};
:
NSLog( @"%f", now_ms() ); // inside a CADisplayLink tick-event
It gives the same value each time.
I can fix this by making a Lambda:
double (^now_ms)(void) = ^() {
return 1000.f * [[NSDate date] timeIntervalSince1970];
};
NSLog( @"%f", now_ms() ); // works!
However I would prefer it to be a free function.
What is going on?
I suspect this is some kind of run-time optimisation.