NSProgressIndicator
has methods called startAnimation:
and stopAnimation:
, but no method that I can find to check the state (whether it is currently animating or not). How would you do it?
You could just keep a BOOL
value somewhere in your class that you set to YES
or NO
when you start and stop the animation respectively.
You should not be storing the state of a control in the control itself.
The progress indicator control doesn't provide access to its animated state because unlike something like a text field, the user can't change the state of the control. You will never be in a situation where the state of the control changes without your code initiating it. Because you are the one who sets the state of it, so you should keep track of it.
Cocoa uses the Model-View-Controller pattern and a progress indicator is a view. If you store state in the control then you are violating the MVC pattern.
Your View should reflect your Model at all times, and the Controller is there to ensure the view and model are kept in sync.
You should either use Cocoa Bindings to bind the animated state of your progress indicator to a BOOL
stored in your model (preferred) or implement code in your controller class to control the animated state of the progress indicator when there is a change to a BOOL
stored in your model.
isAnimating
property for for NSProgressIndicator
(at least I can't find it in the docs), thus there is no way to use Cocoa Bindings for this :( –
Hirsh animate
property. –
Pater You could just keep a BOOL
value somewhere in your class that you set to YES
or NO
when you start and stop the animation respectively.
© 2022 - 2024 — McMap. All rights reserved.