Question

I would like to add a NSProgressIndicator. I have a button which enable a timer, then after the delay, a method is called.

I would like to start the spinning animation when I press the button, and I would like to stop animation when the method ends.

So, in my .h I added

NSProgressIndicator * ConnectingProgress;

Then in my .m in my button action I added

 [ConnectingProgress startAnimation:sender];

And for last at the end of my method I added

[ConnectingProgress stopAnimation:sender];

The issues:

  1. the "sender" is not recognized in my method.
  2. nothing work, also the startAnimation...

What I did wrong and How can I passtrhough?

Was it helpful?

Solution

The compiler is saying you that you don't have any local variable sender. Pass self (a view controller reference) directly or declare sender as

id sender = self;
[ConnectingProgress startAnimation:sender];

and

id sender = self;
[ConnectingProgress stopAnimation:sender];

What's the reason to declare a NSProgressIndicator variable ConnectingProgress starting with a capital C ? The capital starting letters are used for class, categories, etc. names, use connectingProgress instead.

I hope the connectingProgress is initialized somewhere (probably at viewDidLoad) and added as a subView somewhere.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top