On Sep 26, 2017, at 01:16 , Tamas Nagy <tamas.lov.n...@gmail.com> 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 (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