1

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".

This is my code in first view controller for push second: (With instruments, using zombie i get a zombie message on this method).

-(void)apriCassettoRivista {
    [NSObject cancelPreviousPerformRequestsWithTarget:self];
    Secondviewcontroller *rivista = [[Secondviewcontroller alloc] init];
    [self.navigationController pushViewController:rivista animated:true];
}

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:

-(IBAction)indietro:(id)sender {
    [NSObject cancelPreviousPerformRequestsWithTarget:self];
    [self.navigationController popViewControllerAnimated:TRUE];
}

Can anyone help me? here is screen of zombie message: http://vincentvega.net/iphone/schermo.png

In my second controller i have observer , too but i destroy them on view will disappear of secondviewcontroller.

UPDATE After several test i detect the problem is caused by render of CGPDFPageRef inside CATiledLayer..if I disable this function my app never crash.

SOLVED The solution was setting nil the delegate of all uiview catiledlayer in my scrollview with this function:

-(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];
                    }
                }

            }

        }

    }
}
Simone M
  • 677
  • 1
  • 10
  • 26

0 Answers0