Re: Problem using NSTimer in privileged helper tool
Re: Problem using NSTimer in privileged helper tool
- Subject: Re: Problem using NSTimer in privileged helper tool
- From: Quincey Morris <email@hidden>
- Date: Fri, 20 Oct 2017 09:56:14 -0700
On Oct 20, 2017, at 03:23 , Mark Allan <email@hidden> wrote:
>
> That worked with the block-based NSTimer API but not the selector-based API.
> I tried changing it to 'currentRunLoop' which got rid of the crash, but the
> timer never fired.
This is pure guesswork, but I suspect this is what was going on:
— When you scheduled the timer on the main run loop, it was actually being
scheduled on the main app’s run loop. When it was block based, only the block
had to be passed across the XPC interface (which somehow works), but when it
was selector-based, the timer itself had to be passed (which doesn’t work).
Admittedly this is a pretty silly explanation, but it may have some relation to
the truth.
— When you scheduled the timer on the current run loop, everything was fine
either way, except the run loop *wasn’t running* in the XPC thread, so the
timer never fired.
This is similar to a problem that came up on the developer forums a few weeks
ago. A developer was using Disk Arbitration callbacks to monitor volumes being
mounted, and tried to move that code to an XPC process. The callback was
scheduled on the run loop, yet it was never called. There was more recent API
that was block-based instead, and that turned out to work fine in an XPC
process. The fact that scheduling on the run loop didn’t crash indicated that
there *was* a run loop, but the fact that the callbacks didn’t fire suggested
that it wasn’t running.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden