On 19. Oct 2017, at 18:04, Mark Allan <markjal...@gmail.com> wrote: > So I tried refactoring the block into a separate method and using an older > NSTimer method: > [NSTimer timerWithTimeInterval:0.2 target:self > selector:@selector(updateTheDelegateForRunID:) userInfo:runID repeats:YES]; > > > This causes my privileged helper tool to crash with the following message > printed to Console: > > Terminating app due to uncaught exception 'NSInvalidArgumentException', > reason: '*** -[NSXPCEncoder _checkObject:]: This coder only encodes objects > that adopt NSSecureCoding (object is of class '__NSCFTimer').'
What kind of class is 'self' in this case, and is the -updateTheDelegateForRunID: method part of your XPC protocol? Methods called by an NSTimer must have the form -(void) foo: (NSTimer*)sender So in this case, the first argument passed to -updateTheDelegateForRunID: will be the timer itself. If the method call is bridged over XPC, this would mean it would try (and fail) to secure code an NSTimer. I don't think clang knows enough about NSTimer to be able to tell that the SEL passed to it should take an NSTimer* argument, so you're not getting a type error, even though you are passing a method that takes the wrong type. Also, your parameter is probably not what you think it should be. You are passing something named runID to your timer's userInfo. This will initialize the timer's userInfo property with that value. It is not the value that gets passed to -updateTheDelegateForRunID:. So my guess is what you really need is an intermediate "timer fired" adapter method: -(void) updateTheDelegateForRunIDTimerFired: (NSTimer*)sender { [self updateTheDelegateForRunID: [sender userInfo]]; } and pass that as the timer's selector instead. Cheers, -- Uli Kusterer "The Witnesses of TeachText are everywhere..." http://www.zathras.de _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com