tags:

views:

26

answers:

0

For the problem I described in http://stackoverflow.com/questions/3089651/cabasicanimation-animates-everything-when-it-should-only-animate-one-thing

I also need to be able to clear all of the layers and draw new ones. I tried looping through all of them and removing all of the sub layers and then the parent layers, but it either didn't work or it crashed. What is the right way to do it?

- (void)clearImageLayers {
    for (int i = 0; i < [images count]; i++) {
        ImageClass *image = [images objectAtIndex:i];
        [image.myLayer removeAllAnimations];
/*      for (CALayer *imagelayer in [[image.myLayer.sublayers copy] autorelease]) {
            [imagelayer removeFromSuperlayer];
        }
        image.myLayer.sublayers = nil;
//      [image.myLayer release];
//      image.myLayer = nil;
    }
}