I am following a tutorial of making custom table view cell with storyboard. I drag a UILabel as subview of the cell and set its tag to 1. I have two questions regarding the data source code.
-
What’s the purpose of the second dequeue statement? I know it’s an init method while not using storyboard to make the custom cell.
-
What’s the difference between tableview and self.tableview?
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier]; } NSDictionary *dToAccess = (self.tableView==tableView)?[self.arForTable objectAtIndex:indexPath.row] : [self.arForSearch objectAtIndex:indexPath.row]; [(UILabel*)[cell viewWithTag:1] setText:[dToAccess valueForKey:@"name"]]; [(UILabel*)[cell viewWithTag:2] setText:[dToAccess valueForKey:@"value"]]; return cell; }
To dequeue twice is not necessary, this block of code is broken.