我对 plist 文件中的值进行计数有问题,问题是 if 语句应该检查该值是否大于我的 plist 中的对象,然后停止移动到下一页,这是我的代码,但是:
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]];
但是当照片到达最后一页后,应用程序将崩溃,调试器消息:
'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (30) beyond bounds (30)'
*** First throw call stack: