I am a problem with counting values in a plist file ,the problem is the if statement should check if the value is greater than objects in my plist , then stop moving to next pages , here is my code but :
picturesDictionary = [NSDictionary dictionaryWithContentsOfFile:
[[NSBundle mainBundle] pathForResource:@"images" ofType:@"plist"]];
arrays = [picturesDictionary objectForKey:@"PhotosArray"];
int photoCount = [arrays count];
if ((photoNumber < 1) || (photoNumber > photoCount)) return nil;
controller = [BookController rotatableViewController];
PhotosInAlbum.image = [UIImage imageNamed:[arrays objectAtIndex:pageNumber]];
but after when photos reach to the last page , application will crash , debugger message :
'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (30) beyond bounds (30)'
*** First throw call stack:
[NSArray count]gives you the number of items in the array, not the index of the last item.