{"action":"created","issue":{"url":"https://api.github.com/repos/RxSwiftCommunity/RxDataSources/issues/75","repository_url":"https://api.github.com/repos/RxSwiftCommunity/RxDataSources","labels_url":"https://api.github.com/repos/RxSwiftCommunity/RxDataSources/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/RxSwiftCommunity/RxDataSources/issues/75/comments","events_url":"https://api.github.com/repos/RxSwiftCommunity/RxDataSources/issues/75/events","html_url":"https://github.com/RxSwiftCommunity/RxDataSources/pull/75","id":190360913,"number":75,"title":"Check the section index on tableView:numberOfRowsInSection: call","user":{"login":"sgl0v","id":1142033,"avatar_url":"https://avatars.githubusercontent.com/u/1142033?v=3","gravatar_id":"","url":"https://api.github.com/users/sgl0v","html_url":"https://github.com/sgl0v","followers_url":"https://api.github.com/users/sgl0v/followers","following_url":"https://api.github.com/users/sgl0v/following{/other_user}","gists_url":"https://api.github.com/users/sgl0v/gists{/gist_id}","starred_url":"https://api.github.com/users/sgl0v/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgl0v/subscriptions","organizations_url":"https://api.github.com/users/sgl0v/orgs","repos_url":"https://api.github.com/users/sgl0v/repos","events_url":"https://api.github.com/users/sgl0v/events{/privacy}","received_events_url":"https://api.github.com/users/sgl0v/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-18T16:25:52Z","updated_at":"2016-12-07T17:35:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/RxSwiftCommunity/RxDataSources/pulls/75","html_url":"https://github.com/RxSwiftCommunity/RxDataSources/pull/75","diff_url":"https://github.com/RxSwiftCommunity/RxDataSources/pull/75.diff","patch_url":"https://github.com/RxSwiftCommunity/RxDataSources/pull/75.patch"},"body":"The `tableView:numberOfRowsInSection:` method might be called before the `numberOfSections`. Thus we should validate the section index to prevent the `Index out of range` error. \r\n\r\n\r\nHere is the example that causes a crash:\r\n```\r\nstruct SectionOfCustomData {\r\n    var items: [Item]\r\n}\r\nextension SectionOfCustomData: SectionModelType {\r\n    typealias Item = String\r\n    \r\n    init(original: SectionOfCustomData, items: [Item]) {\r\n        self = original\r\n        self.items = items\r\n    }\r\n}\r\n\r\nclass RxTableViewController: UIViewController {\r\n    \r\n    var tableView: UITableView!\r\n    let disposeBag = DisposeBag()\r\n    \r\n    let dataSource = RxTableViewSectionedReloadDataSource<SectionOfCustomData>()\r\n    \r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        \r\n        self.tableView = UITableView(frame: self.view.bounds, style: .plain)\r\n        self.view.addSubview(self.tableView)\r\n\r\n        self.tableView.tableFooterView = UIView()\r\n        self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: \"Cell\")\r\n        self.tableView.rowHeight = UITableViewAutomaticDimension\r\n        self.tableView.estimatedRowHeight = 100\r\n\r\n        Observable.just([SectionOfCustomData]()).asDriver(onErrorJustReturn: []).drive(tableView.rx.items(dataSource: self.dataSource))\r\n            .addDisposableTo(disposeBag)\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/RxSwiftCommunity/RxDataSources/issues/comments/265515304","html_url":"https://github.com/RxSwiftCommunity/RxDataSources/pull/75#issuecomment-265515304","issue_url":"https://api.github.com/repos/RxSwiftCommunity/RxDataSources/issues/75","id":265515304,"user":{"login":"kzaher","id":1641148,"avatar_url":"https://avatars.githubusercontent.com/u/1641148?v=3","gravatar_id":"","url":"https://api.github.com/users/kzaher","html_url":"https://github.com/kzaher","followers_url":"https://api.github.com/users/kzaher/followers","following_url":"https://api.github.com/users/kzaher/following{/other_user}","gists_url":"https://api.github.com/users/kzaher/gists{/gist_id}","starred_url":"https://api.github.com/users/kzaher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kzaher/subscriptions","organizations_url":"https://api.github.com/users/kzaher/orgs","repos_url":"https://api.github.com/users/kzaher/repos","events_url":"https://api.github.com/users/kzaher/events{/privacy}","received_events_url":"https://api.github.com/users/kzaher/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T17:35:28Z","updated_at":"2016-12-07T17:35:28Z","body":"Hi @hariseldon78 @sgl0v ,\r\n\r\nyour experience basically means that there is a somewhere a problem with data synchronization.\r\n\r\nIf that problem is somewhere in this library then we need to find that place and fix it there. \r\n\r\nPatching this one method won't do any good since if that problem exists it can also cause wrong number of rows being reported etc ...\r\n\r\nI haven't had any issues with latest version in production so it is also possible that @hariseldon78 you are experiencing some local issue. \r\n\r\nTry to check if you are updating UI data that table view depends on from background thread. If that is the case, then this is where the error probably lies.\r\n\r\nIf this is not the case then we need some more info to help us locate the real issue."}}
{"actor":{"display_login":"kzaher"}}