In the classic pattern below the returned cell from dequeueReusableCellWithIdentifier is always non nil. Why? Shouldn’t we have to allocated some cell first then we can have some to be reused?
I am using a customize cell and it was created in the storyboard. (However, if I had used the default UITableViewCell ,the phenomena is same – the returned cell is still always non-nil).
Enviroment: Xcode 4.3.3 iOs 5.1
AlbumListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AlbumCell"];
//cell always non nil --- why??
if(cell == nil){
cell = [[AlbumListCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"AlbumCell"];
}
If you’re using storyboard and set the UITableViewCell’s Identifier to the identifier to the one you are using in dequeueReusableCellWithIdentifier (“AlbumCell” in your case) in the storyboard file, the UITableView will always create cells for you. I guess this is a feature of storyboard. If the identifier can’t be found in your storyboard, then you need to create cells manually.