Possible Duplicate:
NSTimer doesn't stop
this is something strange ,, i am calling alert button inside appDidfinsh method and based on that click i am calling a method defined in viewController to stop timer but i cant stop however i can access my method
-
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"check" message:@" this is 2nd time!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: @"Update",nil];
[alert show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex == 1) {
DatabaseTestViewController *vv=[ [DatabaseTestViewController alloc]init];
[viewController handleTime];
[vv handleTime];
}
}
////////////// now in view controller class
- (void)viewDidLoad {
[super viewDidLoad];
NSUserDefaults *getid = [NSUserDefaults standardUserDefaults];
getMode = [getid stringForKey:@"AppMode"];
timer = [NSTimer scheduledTimerWithTimeInterval: .8
target: self
selector: @selector(handleTimer)
userInfo: nil
repeats: YES];
}
- (void) handleTimer: (NSTimer *) timer
{
NSLog(@"getModis is %@",getMode);
// [self.tabelView reloadData];
//[super viewDidLoad];
} //
-(void) handleTime
{
[self.tabelView reloadData];// this is also not updating my data i actually need this
[timer invalidate];// not working , timer still running but i can access this method
[timer release];
timer =nil;
}