I have 2 ViewController(RootViewController is UITabBarController, ViewController1 links to the item of UITabBarController)
in RootViewController
-(void)startTimer:(NSInteg开发者_StackOverflow社区er)v;
{
[NSTimer scheduledTimerWithTimeInterval:10
target:self
selector:@selector(timerFired:)
userInfo:nil
repeats:YES];
}
- (void)timerFired:(NSTimer *)timer {
[vViewController1 doSomething];
}
in ViewController1
-(void)doSomething;
{
//I set breakpoint but never be fired
}
timerFired is activated but the function doSomething in ViewController1 never been fired.
Welcome any comment
Thanks
interdev
If you know for a fact that timerFired: is being called, then the only reason that doSomething won't get called is if vViewController1 is nill. Check that again.
The self
in scheduledTimerWithTimeInterval
target:self
means RootViewController, so it will only invoke doSomething
in RootViewController but not in ViewController1.
精彩评论