From 1ef6478312657781f9e2de85875f749bdf6b96a2 Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Mon, 10 Mar 2014 10:16:59 +0100 Subject: [PATCH] Protect scrollToBottom --- Classes/ChatRoomTableViewController.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Classes/ChatRoomTableViewController.m b/Classes/ChatRoomTableViewController.m index 04125d2bd..2476edc2a 100644 --- a/Classes/ChatRoomTableViewController.m +++ b/Classes/ChatRoomTableViewController.m @@ -94,9 +94,11 @@ - (void)scrollToBottom:(BOOL)animated { [self.tableView reloadData]; - [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:([data count] - 1) inSection:0] - atScrollPosition:UITableViewScrollPositionBottom - animated:YES]; + if( [data count] ){ + [self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:([data count] - 1) inSection:0] + atScrollPosition:UITableViewScrollPositionBottom + animated:YES]; + } } - (void)scrollToLastUnread:(BOOL)animated {