title: iOS application crashes when using [UIImageView startAnimating] method
body: <p>in my nib file I have a UIImageView that I have linked to my variable <code>IBOutlet UIImageView* imgH6;</code>  I need to play several animations therefore I have decided to play them on imgH6. for example if I want to start animating a group of images I will do: <code>[self playAnimation1];</code></p>
  
  <pre><code>-(void) playAnimation1{
  
     NSArray *imagesArrayDilema;
  
     imagesArrayDilema = [NSArray arrayWithObjects:
                                   [UIImage imageNamed:@"dilema1-02.png"], 
                                   [UIImage imageNamed:@"dilema1-03.png"], 
                                   [UIImage imageNamed:@"dilema1-04.png"], 
                                   [UIImage imageNamed:@"dilema1-05.png"] 
                                   // .....
                                   // there are several images
                                   , nil];
  
     imgH6.animationImages = imagesArrayDilema;
  
     // I will then start the animation as:
     wait = ((double)[imgH6.animationImages count])/30;
     [imgH6 setAnimationRepeatCount:1];
     imgH6.animationDuration = wait;
     [imgH6 startAnimating];
  }
  
  
  
  -(void) playAnimation2{
  
     NSArray *imagesArrayDilema;
  
     imagesArrayDilema = [NSArray arrayWithObjects:
                                   [UIImage imageNamed:@"differentImage-01.png"], 
                                   [UIImage imageNamed:@"differentImage-02.png"], 
                                   [UIImage imageNamed:@"differentImage-03.png"], 
                                   [UIImage imageNamed:@"differentImage-04.png"], 
                                   // .....
                                   // there are several images
                                   , nil];
  
     imgH6.animationImages = imagesArrayDilema;
  
     // I will then start the animation as:
     wait = ((double)[imgH6.animationImages count])/30;
     [imgH6 setAnimationRepeatCount:1];
     imgH6.animationDuration = wait;
     [imgH6 startAnimating];
  }
  
   ///.....
   // ...
  -(void) playAnimation8{ // etc...
  </code></pre>
  
  <p>so when I call <code>[self playAnimation1];</code> there is no problem. the animation animates fine. I may also call <code>[self playAnimation7];</code> and a different group of images animate. I am able to do this several times but eventually the application crashes! In order to fix this I have done the following:  I have a global BOOL variable called isAnimating and what that does is that every time there is an animation in place you will not be able to animate a different group of images until the animation is done. Before I used to have the method:</p>
  
  <pre><code>-(void) animateMain :(NSArray*) imagesArray{
  
         imgH6.animationImages = imagesArray;
  
         // I will then start the animation as:
         double wait = ((double)[imgH6.animationImages count])/30;
         [imgH6 setAnimationRepeatCount:1];
         imgH6.animationDuration = wait;
         [imgH6 startAnimating];
  
  
  }
  </code></pre>
  
  <p>and the application still crashed after playing several times. I have noticed that it crashes when changing the animation several times. In other words if I alway splay the same animation it does not crash...</p>
  
  <p>also I do not used the word alloc or init to instantiate the array so I don't think this has to do with releasing the array. </p>