0

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;
    }
Community
  • 1
  • 1
prajakta
  • 663
  • 6
  • 26
  • Your app is probably just being killed by the watchdog or dying after your method returns (you call [timer release] but you never owned timer, so you can't release it). Also don't reload your data when the app is terminating. You only have a few seconds before the watchdog kills you. Check your crash logs for tons of 8badf00d crashes. – Jason Coco Dec 29 '10 at 07:24
  • so how to call [self.tabelView reloadData]; i need this based on alert click help me – prajakta Dec 29 '10 at 07:40
  • It's not advised to ask for user interaction when your application should terminate. The user presses the home button and she's expecting to see the home screen, not an alert box. – scalbatty Dec 29 '10 at 08:49
  • oops that was - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { sorry ... now how to acesss [self.tabelView reloadData]; – prajakta Dec 29 '10 at 09:19

0 Answers0