У меня есть UITableView, который содержит 3 NSArrays и 3 NSDictionaries для каждого массива.проблемы с несколькими разделами UITableView
- (void)viewDidLoad {
[super viewDidLoad];
contentArray = [[NSMutableArray alloc] init];
self.settingsArray = [NSArray arrayWithObjects:@"Settings", nil];
NSDictionary *settingsDict = [NSDictionary dictionaryWithObject:settingsArray forKey:@"Settings"];
self.infoArray = [NSArray arrayWithObjects: @"Version 1.0", @"© Copyrights 2010", @"Developer Site", @"App Page", @"Report a Bug", nil];
NSDictionary *infoDict = [NSDictionary dictionaryWithObject:infoArray forKey:@"Settings"];
self.contactArray = [NSArray arrayWithObjects: @"Developer Site", @"App Page", @"Report a Bug", nil];
NSDictionary *contactDict = [NSDictionary dictionaryWithObject:contactArray forKey:@"Settings"];
[contentArray addObject:infoDict];
[contentArray addObject:settingsDict];
[contentArray addObject:contactDict];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([[infoArray objectAtIndex:indexPath.row] isEqual:@"Version 1.1"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if ([[infoArray objectAtIndex:indexPath.row] isEqual:@"© Copyrights 2010"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if ([[settingsArray objectAtIndex:indexPath.row] isEqual:@"Settings"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"NULL" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
if ([[contactArray objectAtIndex:indexPath.row] isEqual:@"Developer Site"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if ([[contactArray objectAtIndex:indexPath.row] isEqual:@"App Page"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
if ([[contactArray objectAtIndex:indexPath.row] isEqual:@"Report a Bug"]) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
}
Проблема заключается в том, когда я пытаюсь выбрать строку, приложение сбой
Благодарности
Какое сообщение об ошибке регистрируется? – Kurbz
2010-07-25 21: 58: 19.355 Двойной поиск [48109: 207] *** Завершение приложения из-за неперехваченного исключения «NSRangeException», причина: *** - [NSCFArray objectAtIndex:]: индекс (4) за пределами границ (1)» 2010-07-25 21: 58: 19,355 Dual Search [48109: 207] Стек: ( 43292752, 44450604 , 43030283, 43030122 , 748457, 187239, 49603, 3416117, 3375658, 330631, 42571740, 42567848 , 51927197, 51927394 , 3056498, 9476,) завершение вызова после вызова экземпляра 'NSException' – 2010-07-25 18:58:47