You have a UITableView
. It has a datasource that provides it UITableViewCell
s. To save memory and processor cycles, it unloads UITableViewCell
s that are no longer on screen and puts them into a reuse queue. When it loads a new cell, the datasource will typically ask the UITableView
for a cell from this reuse queue. If the queue is currently empty, UITableView
will construct a new UITableViewCell
using the class provided. The reuseIdentifier
is used to distinguish this particular cell type queue from another cell type queue within the same UITableView
.
Something like this:
UITableView
: "Hey, Datasource! Give me the cell for this indexPath."
Datasource
: "Alright. That's a 'foo' kind of cell. Got any of those kicking around that you're not using?"
No class registered; reuse cells returned from datasource previously
UITableView
: "Yes, I do. Here you go."
No class registered; no cells available
UITableView
: "Nope. Hey, I don't have a class registered for that kind of cell. Hmm. Here's nil
instead."
Class registered; reuse cells returned from datasource previously
UITableView
: "Yes, I do. Here you go."
Class registered; no cells available
UITableView
: "Nope. But I have a class registered for that identifier. Here's a new instance."
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…