I have a UITableViewCell subclass that has a large thumbnail thumbnail in each cell along with a title. The cell may be showing a video, an image, a gallery of photos, or a drawing.

Depending on which of these content types the cell is displaying, the thumbnail will have a small icon on top to make it clear what kind of content is being shown in the cell. So for example if the cell was showing a video, it would have the thumbnail with maybe the triangle play icon on top to show that it's a video. A drawing may have a pencil.

I want to do this in a way that is organized and follows MVC, because I'm trying to learn to keep my code organized and maintainable.

My first thought was to have a UITableViewCell subclass for every content type, but that seems like a lot of different classes to maintain when the only thing that changes is a small icon on top.

My next thought was to have a type instance variable on the class denoting what it is showing, and then show the icon corresponding to the type. But in this case, isn't the cell a view (the V) in MVC, and is the view supposed to handle the logic in displaying it as well?

Is there something better yet?

And lastly, how does this work in conjunction with Interface Builder? If it's the latter solution, do I add them all in IB as hidden, then unhide them programmatically depending on the type?

Related posts

Recent Viewed