Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 索引100超出边界0。。。99 swipeDetected void中的错误_Iphone_Xcode_Arrays_Dictionary_Bounds - Fatal编程技术网

Iphone 索引100超出边界0。。。99 swipeDetected void中的错误

Iphone 索引100超出边界0。。。99 swipeDetected void中的错误,iphone,xcode,arrays,dictionary,bounds,Iphone,Xcode,Arrays,Dictionary,Bounds,在这里它很好用。若我尝试从索引中的第一个对象向右(向后)滑动,则不会发生任何事情 - (void)swipeDetectedRight:(UISwipeGestureRecognizer *)sender { if (detailIndex != 0) detailIndex--; Label.text = [[detailsDataSource objectAtIndex: detailIndex] valueForKey:@"Text"]; } 但当我在最后一个条目(NR10

在这里它很好用。若我尝试从索引中的第一个对象向右(向后)滑动,则不会发生任何事情

- (void)swipeDetectedRight:(UISwipeGestureRecognizer *)sender
{
if (detailIndex != 0)
    detailIndex--;  

Label.text = [[detailsDataSource objectAtIndex: detailIndex] valueForKey:@"Text"];
}
但当我在最后一个条目(NR100)上向左滑动时,它崩溃了。这是左边的代码:

- (void)swipeDetectedLeft:(UISwipeGestureRecognizer *)sender
{
    if (detailIndex != [detailsDataSource count])
        detailIndex++;


    Label.text = [[detailsDataSource objectAtIndex: detailIndex] valueForKey:@"Text"];
}
和错误消息:

-[\uu NSArrayI objectAtIndex:]:索引100超出范围[0..99]'

如何正确设置边界,使其不会掠过最后一个对象

- (void)swipeDetectedLeft:(UISwipeGestureRecognizer *)sender
{

if (detailIndex != 99)
    detailIndex++;
}