Search code examples
iphoneeventscadisplaylink

On the iPhone, is it possible for a touchesBegan:withEvent to fire while a CADisplayLink callback method is executing?


Wouldn't the touchesBegan:withEvent always fire "before" or "after" each iteration of the CADisplayLink callback?

Edit: Here's my CADisplayLink instantiation:

CADisplayLink *aDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(tick:)];
[aDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

Solution

  • Assuming that the display link is connected to the main run loop then yes — it would be impossible for the two to occur at the same time. Cocoa's run loops queue up messages to send, then send them one at a time.