Verify that the NSAnimationContext runAnimationGroup is canceled or completed

I revive the presentation (revealing it), after which I need to send a notification (after the animation is completed). However, as the application is developed, there another notification is sent when the view is hidden (via animation). So essentially I have a showView and "hideView" method. Everyone does something like this:

[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) { [context setDuration: 0.25]; [[myView animator] setAlphaValue: 0]; } completionHandler:^{ // post notification now }]; 

The problem is that in another thread in the background, I have a periodic timer that performs a “health check” to see if the view should be hidden if it is not needed. This is an aggressive approach, but necessary because many application components respond to various events and scenarios. Because of this, I sometimes get “race status” when the user clicks the “showView” button, but at the same time one of our threads thinks that the view should be hidden immediately.

When both send a notification on the main thread, the application freezes endlessly in SpinLock. I could completely avoid this situation if I could find out if the animation block above was canceled (i.e., another animation block executed on the same view). In such situations, I would not post a notice that would then not force a check.

In short: I need to check if the "terminated host" was called after the animation was completed or if it was canceled. I know that in iOS it is possible, but I can’t find a way to do it in OS X. Please help.

+6
source share

Source: https://habr.com/ru/post/953727/


All Articles