Cycle backwards through NSArray
<p>I'm trying to cycle backwards through an array by clicking a button. </p>

<p>My current code is close, but doesn't quite work.</p>

<pre><code>- (void)viewDidLoad {
self.imageNames = [NSArray arrayWithObjects:@"MyFirstImage", @"AnotherImage", nil];
currentImageIndex = 0;
[super viewDidLoad];
}
</code></pre>

<p>...what works:</p>

<pre><code>- (IBAction)change {
UIImage* imageToShow = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[imageNames objectAtIndex:currentImageIndex] ofType:@"png"];
currentImageIndex++;
if (currentImageIndex &gt;= imageNames.count) {
    currentImageIndex = 0;
}
}
</code></pre>

<p>...and what isn't working:</p>

<pre><code>- (IBAction)changeBack {
UIImage* imageToShow = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[imageNames objectAtIndex:currentImageIndex] ofType:@"png"];
currentImageIndex--;
if (currentImageIndex &gt;= imageNames.count) {
    currentImageIndex = 0;
}
}
</code></pre>

<p>Any help is gladly appreciated! </p>

<p>Thanks!</p>
