0

我在我的 Crashalytics 中遇到了这个异常:

0    CoreFoundation 
__exceptionPreprocess + 162
1    libobjc.A.dylib    
objc_exception_throw + 30
2    CoreFoundation 
-[NSException initWithCoder:]
3    CoreFoundation 
-[__NSCFArray objectAtIndex:] + 136
4    BusinessPlan ✭  BusinessController.m line 167
-[BusinessController tableView:didSelectRowAtIndexPath:] + 167
5    UIKit  
-[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 876
6    UIKit  
-[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 156
7    Foundation 
__NSFireDelayedPerform + 450
8    CoreFoundation 
__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
9    CoreFoundation 
__CFRunLoopDoTimer + 272
10   CoreFoundation 
__CFRunLoopRun + 1232
11   CoreFoundation 
CFRunLoopRunSpecific + 356
12   CoreFoundation 
CFRunLoopRunInMode + 104
13   GraphicsServices   
GSEventRunModal + 74
14   UIKit  
UIApplicationMain + 1120
15   BusinessPlan    main.m line 16
main + 16
16   BusinessPlan   
start

它被称为:

Exception Type: NSRangeException
Reason: -[__NSCFArray objectAtIndex:]: index (14) beyond bounds (14)

它只发生过一次,所以我不知道如何重现它。但它发生在这段代码中:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{        
    NSDictionary *info = [topics_array objectAtIndex:indexPath.row]; 
    NSString *section_name = [info objectForKey:@"section_name"];
    NSString *solution_section_id = [info objectForKey:@"solution_section_id"];

    // PUT THESE ITEMS INTO THE SESSION
    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];

    [standardUserDefaults setObject:section_name forKey:@"section_name"];
    [standardUserDefaults setObject:solution_section_id forKey:@"solution_section_id"];

    [standardUserDefaults synchronize];

    [self performSegueWithIdentifier:@"BusinessToTopic" sender:self];
}

有谁知道如何防止这种情况在未来发生以及为什么会发生?

编辑:

这是 tableView numberOfRowsInSection 的代码

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{    
    return [tableLabels count]; 
}

谢谢!

4

0 回答 0