On the actions for the button presses, before you change the image check the index of the image you are about to set. If it is smaller than 0, set it to the highest index in the array (array.count), and if it is larger than highest index in the array (array.count) set the index to 0.
here is some psudo code
Code:
-(IBAction)NextImage
{
if (index > array.count)
index = 0;
...change image here
}
-(IBAction)LastImage
{
if (index < 0)
index = array.count;
...change image here
}