首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ios崩溃问题- NSRange

ios崩溃问题- NSRange
EN

Stack Overflow用户
提问于 2013-12-04 05:04:53
回答 1查看 2.7K关注 0票数 0

我收到了这个错误消息。

代码语言:javascript
运行
复制
GoogleAnalytics 2.0b3 void GAIUncaughtExceptionHandler(NSException *)     
(GAIUncaughtExceptionHandler.m:41): Uncaught exception: *** -[__NSArrayM objectAtIndex:]: 
index 2 beyond bounds [0 .. 1]
libc++abi.dylib: terminate_handler unexpectedly threw an exception

当我试图缩放页面时,我在crashlytics中遇到了崩溃和这个错误。

代码语言:javascript
运行
复制
Thread : Fatal Exception: NSRangeException
0  CoreFoundation                 0x31a202a3 __exceptionPreprocess + 162
1  libobjc.A.dylib                0x3974897f objc_exception_throw + 30
2  CoreFoundation                 0x3196bb75 -[__NSArrayM objectAtIndex:] + 164
3  TestApp                       0x000b1bfb -[EpisodeTableViewDelegate    
tableView:didSelectRowAtIndexPath:] (EpisodeTableViewDelegate.m:155)
4  UIKit                          0x338ea28d -[UITableView 
_selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 876
5  UIKit                          0x3396cf81 -[UITableView 
_userSelectRowAtPendingSelectionIndexPath:] + 156
6  Foundation                     0x3232e277 __NSFireDelayedPerform + 450
7  CoreFoundation                 0x319f55df __
CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
8  CoreFoundation                 0x319f5291 __CFRunLoopDoTimer + 272
9  CoreFoundation                 0x319f3f01 __CFRunLoopRun + 1232
10 CoreFoundation                 0x31966ebd CFRunLoopRunSpecific + 356
11 CoreFoundation                 0x31966d49 CFRunLoopRunInMode + 104
12 GraphicsServices               0x3553f2eb GSEventRunModal + 74
13 UIKit                          0x3387c301 UIApplicationMain + 1120
14 Tapastic                       0x00075cb7 main (main.m:16)
15 Tapastic                       0x000753b8 start

我的代码如下:

代码语言:javascript
运行
复制
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (indexPath.section == 1) {
        Episode *episode = [[Episode alloc] init];
        [episode bindProperties:[self.pager.contents objectAtIndex:indexPath.row]];
        [self.baseController performSegueWithIdentifier:SEGUE_EPISODE_VIEW sender:episode];
    }
}

我不能解决这个问题。我怎么才能修复它?如果可能的话,请告诉我。提前谢谢。

EN

回答 1

Stack Overflow用户

发布于 2013-12-04 05:11:45

当数组中只有两个对象时,您将对索引为2的episode数组调用objectAtIndex。数组对象从0开始编号,因此包含两个对象的数组只有元素0和1。

听起来你没有正确设置你的UITableView。如果支持该表的数组中只有两个对象,则该表中应该只有两行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20361625

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档