UIButton that cycles through images when clicked
<p>I have three images that I want to cycle through when clicking on a UIButton.</p>

<p>How would I go about doing this?</p>

<p>This is what I have so far, but it's not really working. </p>

<pre><code>//the images
NSString* imageNames[] = {"MyFirstImage", "AnotherImage", whatever else};
int currentImageIndex = 0;
</code></pre>

<p>and </p>

<pre><code>- (IBAction)change{
UIImage* imageToShow = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource: imageNames[currentImageIndex] ofType:@"png"];

if( currentImageIndex++ == sizeof(imageNames)/sizeof(NSString)) //check to see if you hit the last image
{
   currentImageIndex = 0; //start over
}
}
</code></pre>

<p>Ideas?</p>

<p>Any help will be greatly appreciated! Thanks!</p>
