I have an entity that represents a Person and a UITableViewCell subclass that displays a few attributes of said person.
The question is this: where do you normally configure (set the text, picture, etc) the table cell? Do you:
A) Configure it in the UITableViewController subclass while implementing tableView:cellForRowAtIndexPath:?
B) Pass the Person object into the UITableViewCell subclass and let the subclass configure itself?
C) Something entirely different?
Bonus Points
If you answered with option A, what about this?
Let’s say that for the first row in the table view, I need to bold all of the labels’ text. Does that change your opinion at all? You see what I’m getting at here, if you configure the cell in the view controller, the view controller will become bloated with information it doesn’t really need. But, if you put all the configuration inside of the table cell subclass, you lose some reusability. It is definitely a trade-off, but I’m wondering what most engineers choose.
What do you mean by “configure”? Do you mean adding the Person’s data to the cell? I would do this in
cellForRowAtIndexPath:, which is usually part of the view controller (it is common to set the delegate of a table view to the view controller). The Person’s data is ideally part of some model in your application. You can fetch the Person for the cell by using the index path, something likeAnd then use that data to set the values of the cell.