Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.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 [\uu NSArrayI objectAtIndex:]:索引8超出范围[0..7]'_Iphone_Ios6 - Fatal编程技术网

Iphone [\uu NSArrayI objectAtIndex:]:索引8超出范围[0..7]'

Iphone [\uu NSArrayI objectAtIndex:]:索引8超出范围[0..7]',iphone,ios6,Iphone,Ios6,我是iOS开发新手,在我学习教程的过程中,我的应用程序继续崩溃,但我不明白为什么 2012-11-07 11:52:30.657 SliderList[2725:c07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 8 beyond bounds [0 .. 7]' *** First throw call st

我是iOS开发新手,在我学习教程的过程中,我的应用程序继续崩溃,但我不明白为什么

2012-11-07 11:52:30.657 SliderList[2725:c07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 8 beyond bounds [0 .. 7]'
*** First throw call stack:
(0x1c8d012 0x10cae7e 0x1c42b44 0x2cb2 0x10de705 0x15920 0x158b8 0xd6671 0xd6bcf 0x15c52d 0xd5968 0x451bd 0x45552 0x233aa 0x14cf8 0x1be8df9 0x1be8ad0 0x1c02bf5 0x1c02962 0x1c33bb6 0x1c32f44 0x1c32e1b 0x1be77e3 0x1be7668 0x1265c 0x26bd 0x25e5 0x1)
libc++abi.dylib: terminate called throwing an exception

您正在从数组中调用索引不在数组中的对象

基本上你的数组有8个元素0到7,你调用的是索引8

只需更改这一行:

self.keuze.text = [keuzeArray objectAtIndex:(sender.value - 1)];
这一切都应该是可行的,因为你只有8个元素。 在数组中,索引从0开始。所以数组中的最后一个元素索引是7。 如果您尝试获取索引8或更高级别的元素,将发生异常NSRangeException,您的应用程序将崩溃。
因此,当您尝试从数组中获取元素时,请检查数组边界。

您的滑块的最大值超出了模型数组中的元素数。

看起来sliderValueChanged:方法中的UISlider的值为8。由于NSArray中的索引是以零为基础的,因此不能要求超过7的元素


您需要重新配置滑块,将最小值设置为0,最大值设置为7。

您的数组有8个索引为0到7的对象。
您正在尝试访问索引8处的对象。这就是它抛出异常错误的原因。

如果它在UITableView中:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return arrayResponse.count-1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return arrayResponse.count-1;
}