title: Message send to deallocated instance of viewcontroller when popviewcontroller
body: <p>I'm developing an app using ARC with a navigation controller, the first view controller have a button linked to an ibaction that call the push of the second view controller.
  In the second viewcontroler a button pop the view controller to the first one. When popping  sometimes my app crash with error: "-[Secondviewcontroller isKindOfClass:]: message sent to deallocated instance 0xb181c00".</p>
  
  <p>This is my code in first view controller for push second: 
  (With instruments, using zombie i get a zombie message on this method).</p>
  
  <pre><code>-(void)apriCassettoRivista {
      [NSObject cancelPreviousPerformRequestsWithTarget:self];
      Secondviewcontroller *rivista = [[Secondviewcontroller alloc] init];
      [self.navigationController pushViewController:rivista animated:true];
  }
  </code></pre>
  
  <p>The error detected is on the method that push the second view controller.. i 'can't understand this.
  I think the problem is in the second view controller..is possible? when popping second i use the following code:</p>
  
  <pre><code>-(IBAction)indietro:(id)sender {
      [NSObject cancelPreviousPerformRequestsWithTarget:self];
      [self.navigationController popViewControllerAnimated:TRUE];
  }
  </code></pre>
  
  <p>Can anyone help me? here is screen of zombie message: <a href="http://vincentvega.net/iphone/schermo.png" rel="nofollow">http://vincentvega.net/iphone/schermo.png</a></p>
  
  <p>In my second controller i have observer , too but i destroy them on view will disappear of secondviewcontroller.</p>
  
  <p><strong>UPDATE</strong>
  After several test i detect the problem is caused by render of CGPDFPageRef inside CATiledLayer..if I disable this function my app never crash.</p>
  
  <p><strong>SOLVED</strong>
  The solution was setting nil the delegate of all uiview catiledlayer in my scrollview with this function:</p>
  
  <pre><code>-(void)buttavia {
      NSArray *subviews = [mainScrolla subviews];
  
      for (UIView *subview in subviews) {
  
          if ([subview isKindOfClass:[UIScrollView class]]) {
  
              //  Ho uno scrolla
              //
              NSArray *subviewsScrolla = [subview subviews];
              for (UIView *subviewScrolla in subviewsScrolla) {
  
                  if ([subviewScrolla isKindOfClass:[UIView class]]) {
  
                      //  Ho una view nello scrolla
                      //
                      if (subviewScrolla) {
                          ((CATiledLayer *)subviewScrolla.layer).delegate = nil;
                          ((CATiledLayer *)subviewScrolla.layer).contents = nil;
                          [subviewScrolla removeFromSuperview];
                          [subviewScrolla.layer removeFromSuperlayer];
                      }
                  }
  
              }
  
          }
  
      }
  }
  </code></pre>