I make program with recursion in background thread. To avoid stack overflow I use timer. But I face the problem with Timer + GCD. After fire, timer call function once and stop.
There is small code. I use ARC if it's important.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
self.timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerFunction) userInfo:nil repeats:YES];
[self.timer fire];
});
return YES;
}
-(void)timerFunction
{
NSLog(@"Timer Tick");
}
What is the problem?
Sorry for my English. Thanks :)