私は奇妙な問題を抱えています。私のNSTimer CallMeメソッドはCFRunLoopなしでは起動しません。 CFRunLoopを追加すると、CFRunLoopの後の行は決して呼び出されません。私はCFRunLoopとCallMeメソッドの後に両方の行を起動する必要があります。NSTimer with CFRunLoop
EDIT - CFRunLoopについて気にしないでください。ちょうどタイマーが20秒ごとに起動するようにしてください。
Iコードと
int main(int argc, char * const argv[]) {
Updater *theUpdater = [[Updater alloc] init];
NSTimer *theTimer = [theUpdater getTimer];
[theTimer retain];
//CFRunLoopRun();
NSLog(@"I am here"); //If I uncomment CFRUnLoop this line does not get executed
}
@implementationアップデータ
- (NSTimer *)getTimer {
NSLog(@"Timer started");
NSTimer *theTimer;
theTimer = [NSTimer scheduledTimerWithTimeInterval:20.0
target:self
selector:@selector(CallMe:)
userInfo:nil
repeats:YES];
return theTimer;
}
-(void) CallMe:(NSTimer*)theTimer{
NSLog(@"I Never get called");
}
@end