Re: NSTimer
Re: NSTimer
- Subject: Re: NSTimer
- From: Cameron Hayne <email@hidden>
- Date: Wed, 31 Aug 2005 15:41:48 -0400
On 31-Aug-05, at 2:38 PM, Christopher Hickman wrote:
I have an NSTimer that I'm trying to use to periodicly call a
method. The
timer gets created, but it doesn't call my method when it fires.
Here's
my code, do you see anything wrong?
-(void)incrementProgressIndicator;
{
NSLog(@"incrementProgressIndicator"); //Never logs
//progressIndicator is an NSProgressIndicator IBOutlet of this
object
//incrementAmount is a double ivar with a written accessor
if (progressIndicator != nil) {[progressIndicator incrementBy:
[self incrementAmount]];}
}
What is that semicolon doing after the "incrementProgressIndicator"
in the first line?
incrementerInvocation = [NSInvocation
invocationWithMethodSignature:
[self
methodSignatureForSelector:@selector(incrementProgressIndicator)]];
You don't seem to be setting the selector (or target) for that
invocation. Read the docs on 'invocationWithMethodSignature'.
But it would be far easier to just use the methods of NSTimer that
take a selector instead of an invocation.
//incrementerTimer needs to be invalidated after it fires
(iterations) times, so we set up a
//second timer to wait (seconds * iterations) seconds and
invalidate the original timer
You should just keep a counter and check it when your timer fires and
invalidate the timer if the number of iterations has been reached.
--
Cameron Hayne
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >NSTimer (From: Christopher Hickman <email@hidden>) |