> On 19 Oct 2017, at 6:05 pm, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Oct 19, 2017, at 09:04 , Mark Allan <markjal...@gmail.com 
> <mailto:markjal...@gmail.com>> wrote:
>> 
>> Terminating app due to uncaught exception 'NSInvalidArgumentException', 
>> reason: '*** -[NSXPCEncoder _checkObject:]: This coder only encodes objects 
>> that adopt NSSecureCoding (object is of class '__NSCFTimer').'
> 
> It’s very suspicious that the timer itself would be encoded, since that would 
> suggest that the timer itself is being passed back across the interface to 
> the main app. What does the backtrace look like? Ideally there would be 
> something there that tells you what it’s trying to do at that time.
> 
> I don’t know, but I suspect that the block-based NSTimer methods might differ 
> from the selector-based ones in that they use GCD rather than the run loop. 
> If you look at the documentation, the old methods say "schedules it on the 
> current run loop”. The new methods do not.
> 
> That suggests the possibility of using dispatch_source_create and 
> dispatch_source_set_timer directly to create a GCD-based time. It’s not quite 
> as convenient to code, but not hard to get right.


Bingo...I think!

After creating the NSTimer, I was scheduling it on the main run loop with the 
following:
        [[NSRunLoop mainRunLoop] addTimer:self.delegateUpdateTimer 
forMode:NSDefaultRunLoopMode];

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.

Removing NSTimer altogether and replacing it with your suggestion of a 
GCD-based timer works a treat.  Timer fires, no crashing, and the main app sees 
the expected output.


Many thanks
Mark
_______________________________________________

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

Reply via email to