У меня странная проблема.Мой метод NSTimer CallMe не запускается без CFRunLoop.И если я добавлю CFRunLoop, то строка после CFRunLoop никогда не будет вызвана.Я хочу, чтобы обе строки после CFRunLoop и CallMe были запущены.
РЕДАКТИРОВАТЬ - мне плевать на CFRunLoop, просто хочу, чтобы таймер срабатывал каждые 20 секунд.
Я добавил код и комментарии ниже
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
}
@ реализацияUpdater
- (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