Pradheep Narendran P February 2016

Invalidate NSTimer inside UIView sub class

I'm looking for a solution where I'm using NSTimer inside UIView subclass. If I try to performsegue to another view controller, it keeps running in the background. Can anybody help me with this issue ?

Answers


Shehzad Ali February 2016

NSTimer must be declared as a property in your UIView subclass so that it may be accessible in your UIViewController where you are referencing that view.

@property (nonatomic, strong) NSTimer *myTimer;

While performing segue.

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
       [self.myCustomView.myTimer invalidate];
}


RAHUL JOSHI February 2016

try making timer object nil by assigning

  [timerObject invalidate];
  timerObject  = nil;

Post Status

Asked in February 2016
Viewed 2,326 times
Voted 11
Answered 2 times

Search




Leave an answer