Note that there are some explanatory texts on larger screens.

plurals
  1. PONSTimer crash with EXC_BAD_ACCESS on Iphone when invalidate
    primarykey
    data
    text
    <p>I have setup two timers in my application which both repeats every a few seconds. Everything works fine except when is time to invalidate the timers. When the phone is locked, I want to invalidate those timers and then recreate them when the phone is unlocked.</p> <p>Im using the notifications to realize when to invalidate/create the timers.</p> <pre><code> [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notify_didBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notify_willResigneActive:) name:UIApplicationWillResignActiveNotification object:nil]; </code></pre> <p>This is what the notify_didBecomeActive method contains:</p> <pre><code>clockTicker = [[NSTimer scheduledTimerWithTimeInterval: 1 target: self selector: @selector(showActivity) userInfo: nil repeats: YES] retain]; alarmTicker = [[NSTimer scheduledTimerWithTimeInterval: CONST_ALARMTIMER target: self selector: @selector(checkAndLaunchAlarm) userInfo: nil repeats: YES] retain]; </code></pre> <p>This the notify_willResigneActive method contains:</p> <pre><code>if (alarmTicker) { [alarmTicker invalidate]; [alarmTicker release]; alarmTicker = NULL; } if (clockTicker) { [clockTicker invalidate]; [clockTicker release]; clockTicker = NULL; } </code></pre> <p>The problem is that when I debug this on the second timer invalidate I get the error. The weird thing is that if I switch the orders of the timers (like first invalidate the clockTicker).. I still got the error on the second timer.</p> <p>What could I be doing wrong?</p> <p>Thanks, Leonardo </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload