Cell Views in UICollectionView

When I started using UICollectionView, I thought the design pattern would be similar to that of a UITableView.

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:...];
if (!cell) {
  cell = [[UITableViewCell alloc] initWithStyle:... reuseIdentifier:...];
}

So it was curious to me to NOT see this set of seemingly boilerplate code for the UICollectionView equivalent. The reason for this is because doing something like this

ImgurCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier
                                                                forIndexPath:indexPath];

is guaranteed to return a cell. 

Advertisements