• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: NSTimer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSTimer


  • Subject: RE: NSTimer
  • From: "Christopher Hickman" <email@hidden>
  • Date: Wed, 31 Aug 2005 17:08:24 -0400

Solved:  I didn't know how to use NSInvocation correctly.

I had to add calls to -[NSInvocation setSelector:] and -[NSInvocation
setTarget:] before I put it in the NSTimer.  Worked great after it knew what
message it needed to send and where to send it. *blush*

Thanks for the replies that got me digging in the right direction, though.

-----Original Message-----
From: cocoa-dev-bounces+tophu=email@hidden
[mailto:cocoa-dev-bounces+tophu=email@hidden] On Behalf Of
Christopher Hickman
Sent: Wednesday, August 31, 2005 2:39 PM
To: Cocoa Mailing List
Subject: NSTimer

Hi folks,

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]];}
}

-(void)incrementProgressIndicatorEveryTimeInterval:
(NSTimeInterval)seconds iterations:(int)iterations;
{
	NSLog(@"incrementProgressIndicatorEveryTimeInterval: %f iterations:

%i", seconds, iterations);
	NSTimer *incrementerTimer;
	NSInvocation *incrementerInvocation;

	incrementerInvocation = [NSInvocation invocationWithMethodSignature:
								[self
methodSignatureForSelector:@selector(incrementProgressIndicator)]];

	incrementerTimer = [NSTimer scheduledTimerWithTimeInterval:seconds

invocation:incrementerInvocation

repeats:YES];

	//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
	[NSTimer scheduledTimerWithTimeInterval:(seconds*iterations)
			 invocation:[NSInvocation
invocationWithMethodSignature:
							[incrementerTimer
methodSignatureForSelector:@selector(invalidate)]]
			 repeats:NO];

}

 _______________________________________________
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


 _______________________________________________
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>)

  • Prev by Date: Re: Where can I find information on making my program apple scriptable?
  • Next by Date: Re: sampler and dynamic libraries
  • Previous by thread: RE: NSTimer
  • Next by thread: Re: NSTimer
  • Index(es):
    • Date
    • Thread