Dans mon application, j'essaie de faire défiler une UITableView vers le haut une fois après avoir mis à jour le contenu de la table. Cependant, dans certaines circonstances, ma table est vide. Donc, je suis l'exception suivante:iphone dev - comment attraper exception « NSRangeException »
Mettre fin application en raison d'une exception non interceptée 'NSRangeException', raison: « - [UITableView scrollToRowAtIndexPath: atScrollPosition: animation:]: ligne (0) au-delà des limites (0) pour la section (0). '
comment puis-je attraper cette exception? J'ai essayé
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
if (indexPath != nil) {
[EventTable scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionTop animated:YES];
}
mais il n'attrape pas l'exception car indexPath n'est pas nul.
Merci. C'est comme ça que je le fais. if (([eventTable NumberOfSections]> 0) && ([eventTable numberOfRowsInSection: 0]> 0)) { \t \t [eventTable scrollToRowAtIndexPath: [NSIndexPath indexPathForRow: 0 lasection: 0] atScrollPosition: UITableViewScrollPositionTop animé: OUI]; \t} – Brian
&& sera correct au lieu de || ? –
@ S.P cela dépend si vous testez si vous voulez faire défiler ou tester si vous souhaitez annuler. –