Re: [NSButton state] must by used from the main thread
Re: [NSButton state] must by used from the main thread
- Subject: Re: [NSButton state] must by used from the main thread
- From: Tamas Nagy <email@hidden>
- Date: Tue, 26 Sep 2017 10:57:14 +0200
Makes sense, thanks Quincey.
Best,
Tamas
> On 2017. Sep 26., at 10:35, Quincey Morris
> <email@hidden> wrote:
>
> On Sep 26, 2017, at 01:16 , Tamas Nagy <email@hidden
> <mailto:email@hidden>> wrote:
>>
>> but “state” of the NSButton is a NSInteger property, so that should be safe
>> to read from a background thread, right?
>
> Not necessarily. If the setter is thread-unsafe, then it’s possible that the
> getter may retrieve an incorrect value.
>
> It’s not clear whether Apple has audited methods to determine thread safety
> (so that such reported errors represent an actual pitfall), or whether there
> is a general restriction on settable properties of UI objects. Either way,
> prudence dictates that you heed the warning and change the code.
>
> Now that I think about it, getting a button state on a background thread does
> seem like an odd thing to do. Except in the simplest of cases, it does seem
> to open up the possibility of race conditions, since the “when” of the value
> might matter, relative to the timing of the surrounding code.
>
_______________________________________________
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