Dear community. I try to setup NSTimer:
@interface GetExternalInfo : NSOperation {
NSTimer *keepAliveTimerMain;
@property (nonatomic,retain) NSTimer *keepAliveTimerMain;
.m:
@synthesize keepAliveTimerMain
-(void) main;
{
self.keepAliveTimerMain = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(keepAlive:) userInfo:nil repeats:YES];
[keepAliveTimerMain fire];
[[NSRunLoop currentRunLoop] addTimer:self.keepAliveTimerMain forMode: NSDefaultRunLoopMode];
BOOL timerState = [keepAliveTimerMain isValid];
NSLog(@"STAT:Timer Validity is: %@", timerState?@"YES":@"NO");
- (void)keepAlive:(NSTimer *)theTimer
{
BOOL currentState = [self isCancelled];
NSLog(@"STAT:cancelled state is %@.\n",currentState?@"YES":@"NO");
}
In Logs
2011-02-02 18:58:31.041 snow[54705:5d07] STAT:cancelled state is NO. 2011-02-02 18:58:31.042 snow[54705:5d07] STAT:Timer Validity is: YES
i see this only once. No next repeat attempts every 5 seconds any opinions in this case? GC is enabled.