-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
I think if the table is empty, namely that
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [[BNUtilitiesQuick getBizs] count];
}
always return 0
I would expect that -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath should not be called at all
This is important. I am making a program to search through things and sometimes after some searching, there is no result being returned.
However, is called anyway and I got an exception. What should I do?
-tableview:cellForRowAtIndexPath:may be called before the table view has realised it has zero rows and so shouldn’t be called.Therefore your implementation needs to check that the value of the row being passed in is not outside the bounds of your array. If it is, you need to return an empty cell (the documentation states returning
nilwill raise an exception).