私は plist ファイルの値をカウントする際に問題があります。問題は、値が plist 内のオブジェクトよりも大きいかどうかを if ステートメントで確認し、次のページへの移動を停止する必要があることです。ここに私のコードがありますが:
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: