Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSTimer (From: Christopher Hickman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.