Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Releasing an object does not automatically assign nil to the pointer. Add <code>clickTimer = nil;</code> after your release statement. This will prevent another method from accessing an invalid object if it attempts to release <em>clickTimer</em>.</p> <p>To ensure that all of your methods properly set the <em>clickTimer</em> to <em>nil</em>, you might consider creating a method that invalidates the timer for you rather than having each method invalidate the timer:</p> <pre><code>- (void) invalidateClickTimer { // invalidate timer if (clickTimer == nil) return; [clickTimer invalidate]; [clickTimer release]; clickTimer = nil; // stop clicking [[UIApplication sharedApplication] setIdleTimerDisabled:NO]; [click setIsClicking:NO]; [clickerButton setBackgroundImage:[UIImage imageNamed:@"wood.png"] forState:UIControlStateNormal]; [clickerButton setTitle:@"Start" forState:UIControlStateNormal]; [clickStatus setText:[NSString stringWithFormat:@"%d",[click numberOfBeatsToDisplay]]]; [click setClickCount:0]; return; } </code></pre> <p>Then replace the following lines in <code>- (IBAction)clickerPressed:(id)sender</code></p> <pre><code>if ([click isClicking] == YES) { [clickTimer invalidate]; [clickTimer release]; clickTimer = nil; // enable the idle timer when the clicking is turned off [[UIApplication sharedApplication] setIdleTimerDisabled:NO]; [click setIsClicking:NO]; [clickerButton setBackgroundImage:[UIImage imageNamed:@"wood.png"] forState:UIControlStateNormal]; [clickerButton setTitle:@"Start" forState:UIControlStateNormal]; [clickStatus setText:[NSString stringWithFormat:@"%d",[click numberOfBeatsToDisplay]]]; [click setClickCount:0]; } </code></pre> <p>With this line:</p> <pre><code>if ([click isClicking] == YES) { [self invalidateClickTimer]; } </code></pre> <p>Call the new method <code>- (void) invalidateClickTimer</code> from the parent view's UIViewController. Probably in the method <code>- (void)viewWillDisappear:(BOOL)animated</code></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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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