我的应用程序在Simulater 6.1上运行正常,但它在7.0上崩溃。
以下是崩溃日志:
[__NSArrayM objectAtIndex:]: index 1 beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x024595e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x021dc8b6 objc_exception_throw + 44
2 CoreFoundation 0x023fa556 -[__NSArrayM objectAtIndex:] + 246
3 OHUM 0x0003c9b7 -[PatientSelectionViewCon tableView:cellForRowAtIndexPath:] + 503
4 UIKit 0x00cdcd2f -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
5 UIKit 0x00cdce03 -[UITableView _createPreparedCellForGlobalRow:] + 69
6 UIKit 0x00cc103c -[UITableView _updateVisibleCellsNow:] + 2146
7 UIKit 0x00cbf531 -[UITableView _updateVisibleCellsImmediatelyIfNecessary] + 66
8 UIKit 0x00ccd26f -[UITableView _visibleCells] + 35
9 UIKit 0x00ccd2c4 -[UITableView visibleCells] + 33
10 UIKit 0x00cc65c2 -[UITableView _updateAnimationDidStop:finished:context:] + 1484
11 UIKit 0x00cc5da9 __46-[UITableView _updateWithItems:updateSupport:]_block_invoke762 + 90
12 UIKit 0x00c50b75 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 306
13 UIKit 0x00c3a81c -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 267
14 UIKit 0x00c3ab04 -[UIViewAnimationState animationDidStop:finished:] + 80
15 QuartzCore 0x00a41e84 _ZN2CA5Layer23run_animation_callbacksEPv + 304
16 libdispatch.dylib 0x027f14b0 _dispatch_client_callout + 14
17 libdispatch.dylib 0x027df766 _dispatch_main_queue_callback_4CF + 340
18 CoreFoundation 0x024bea5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
19 CoreFoundation 0x023ff72b __CFRunLoopRun + 1963
20 CoreFoundation 0x023feb33 CFRunLoopRunSpecific + 467
21 CoreFoundation 0x023fe94b CFRunLoopRunInMode + 123
22 GraphicsServices 0x044949d7 GSEventRunModal + 192
23 GraphicsServices 0x044947fe GSEventRun + 104
24 UIKit 0x00bee94b UIApplicationMain + 1225
25 OHUM 0x00021fed main + 141
26 libdyld.dylib 0x02a81725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
方法是:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
PatientListCell * cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.delegate = self;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if(indexPath.row == selectedIndex.row){
//Hide all previous dropdown items.
[self removePreviousDropDownItems];
cell.isExpanded = YES;
}
else {
cell.isExpanded = NO;
}
// I check the Array here
if([self.objPatientSelectionVO.arrPatientVO count]==0)
{
return cell;
}
PatientVO * objVO = [self.objPatientSelectionVO.arrPatientVO objectAtIndex:indexPath.row];
[cell setupData:objVO];
cell.tag = indexPath.row;
//Sets the size of the drop down depending on the expanded state of the Cell.
[cell handleExpansion];
return cell;
}
答案 0 :(得分:1)
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
PatientListCell * cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.delegate = self;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
if(indexPath.row == selectedIndex.row){
//Hide all previous dropdown items.
[self removePreviousDropDownItems];
cell.isExpanded = YES;
}
else {
cell.isExpanded = NO;
}
//This check for Array is empty then return cell
if([self.objPatientSelectionVO.arrPatientVO count]==0)
{
return cell;
}
PatientVO * objVO = [self.objPatientSelectionVO.arrPatientVO objectAtIndex:indexPath.row];
[cell setupData:objVO];
cell.tag = indexPath.row;
//Sets the size of the drop down depending on the expanded state of the Cell.
[cell handleExpansion];
return cell;
}
答案 1 :(得分:0)
此数组为空
self.objPatientSelectionVO.arrPatientVO
如果这是你用...填充数据的主数组,则需要在numberOfRows方法中返回数组的计数
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section
答案 2 :(得分:0)
self.objPatientSelectionVO.arrPatientVO
是空的。确保在创建tableView之前添加了对象。你正在从你的数组索引
和
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section{
return self.objPatientSelectionVO.arrPatientVO.count;
}