由于未捕获的异常'NSRangeException'终止应用程序,原因:'*** - [NSMutableArray objectAtIndex:]:索引1超出边界[0 .. 0]' [英] Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 1 beyond bounds [0 .. 0]'

查看:420
本文介绍了由于未捕获的异常'NSRangeException'终止应用程序,原因:'*** - [NSMutableArray objectAtIndex:]:索引1超出边界[0 .. 0]'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误,非常新的iphone开发和目标C.我非常愿意发送我的项目让某人看看,我在圈子里跑,不知道该怎么办下一个!

i'm receiving the following errors, very new to iphone dev and objective C. I am very much willing to send over my project for someone to have a look, i'm running in circles and have no idea what to do next!

2010-11-10 19:38:07.822 iShisha[2698:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSMutableArray objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** Call stack at first throw:
(
 0   CoreFoundation                      0x025f9b99 __exceptionPreprocess + 185
 1   libobjc.A.dylib                     0x0274940e objc_exception_throw + 47
 2   CoreFoundation                      0x025ef695 -[__NSArrayM objectAtIndex:] + 261
 3   iShisha                             0x00003dc5 -[MapViewController tableView:cellForRowAtIndexPath:] + 1262
 4   UIKit                               0x0032dd6f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 619
 5   UIKit                               0x00323e02 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
 6   UIKit                               0x00338774 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
 7   UIKit                               0x003307ec -[UITableView layoutSubviews] + 242
 8   QuartzCore                          0x046d7481 -[CALayer layoutSublayers] + 177
 9   QuartzCore                          0x046d71b1 CALayerLayoutIfNeeded + 220
 10  QuartzCore                          0x046d02e0 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 302
 11  QuartzCore                          0x046d0040 _ZN2CA11Transaction6commitEv + 292
 12  QuartzCore                          0x04700ebb _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
 13  CoreFoundation                      0x025daf4b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
 14  CoreFoundation                      0x0256fb27 __CFRunLoopDoObservers + 295
 15  CoreFoundation                      0x02538ce7 __CFRunLoopRun + 1575
 16  CoreFoundation                      0x02538350 CFRunLoopRunSpecific + 208
 17  CoreFoundation                      0x02538271 CFRunLoopRunInMode + 97
 18  GraphicsServices                    0x02ed800c GSEventRunModal + 217
 19  GraphicsServices                    0x02ed80d1 GSEventRun + 115
 20  UIKit                               0x002caaf2 UIApplicationMain + 1160
 21  iShisha                             0x00001de8 main + 102
 22  iShisha                             0x00001d79 start + 53
)
terminate called after throwing an instance of 'NSException'

[Session started at 2010-11-10 19:38:15 +0000.]
Pending breakpoint 1 - ""MapViewController.m":204" resolved
Pending breakpoint 2 - ""MapViewController.m":317" resolved
Pending breakpoint 3 - "objc_exception_throw" resolved
(gdb) 


推荐答案

CocoaTouch,表有一个委托和一个数据源。委托发送和接收表视图的消息,数据源控制表中的信息以及表的页眉和页脚。数据源告诉表格要绘制的行数,有多少部分,作为节标题放置的内容等等。

In CocoaTouch, tables have a delegate and a data source. The delegate sends and receives messages for the table view, and the data source controls the information that goes in the table and the table's headers and footers. The data source tells the table how many rows to draw, how many sections, what to put as the section titles, etcetera.

表视图查询数据源的方式许多行通过

The table view queries the data source for how many rows to draw via the

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

方法。然后,在

method. Then, in the

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

方法,tableView要求一个单元格从数据源填充表格。在为iPhone编程时,表主要由数组填充,单个变量(对象)包含许多其他变量(对象)。你告诉一个数组你想要什么对象,通过询问

method, the tableView asks for a cell to populate the table from the data source. When programming for the iPhone, tables are mostly populated by an array, a single variable (object) that contains many other variables (objects). You tell an array what object you want, by asking

object = [array objectAtIndex:INTEGER]; //where INTEGER is an unsigned (zero or greater, no minus)

发生了什么,是你的数据源期望表的X个对象,并且有XY可用。如果它认为有10个,但只有9个,当表要求第10个对象时,你会因为没有要提供的对象而崩溃。

what happened, is that your data source is expecting X number of objects for the table, and there are X-Y available. If it thinks there are 10, but there are only 9, when the table asks for the 10th object, you get a crash because there is no object to give.

看起来在你的hte行代码中

look in your code for hte line

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

并查看该代码是什么。你有可能在那里提供错误的数据。

and see what that code is. Chances are you're providing the wrong data there.

祝你好运

这篇关于由于未捕获的异常'NSRangeException'终止应用程序,原因:'*** - [NSMutableArray objectAtIndex:]:索引1超出边界[0 .. 0]'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆