recordingTimer = [NSTimer scheduledTimerWithTimeInterval:0.03
target:self
selector:@selector(recordingTimerSelector:)
userInfo:nil
repeats:YES];
This needs to be very accurate. I’ve been experimenting with it, and it seems to skip a beat every now and again. Is there a better way to run a method every 0.03 seconds?
NSTimer has a resolution of 50 to 100 milliseconds, or 0.05 to 0.1 seconds. You could try CADisplayLink.
That would call your method thirty times a second.
EDIT: I searched around for CADisplayLink’s resolution but couldn’t find much, so I did some testing myself.
I modified some existing code that logs the frame rate using mach_absolute_time() to print the interval in milliseconds between calls to a method I had set up to be called by a CADisplayLink. I did a test on a few hundred time intervals between calls for both CADisplayLink and NSTimer. CADisplayLink had an average deviance (from the target time) of three tenths of a millisecond while NSTimer had an average deviation of half of a millisecond. That’s a decent difference in accuracy considering only a few sprites were rendering to the screen. CADisplayLink was 40% more accurate.
So, my conclusion is that if you want a method to be called
60/n(wherenis a whole integer) times per second, CADisplayLink is vastly superior. You could try running on a different thread as well, where less is going on. That might increase the accuracy of the calls as well.