Nice job creating your own implementation of UITableView. Although, if you find delegates and datasources unusual then its best for you to spend more time getting familiar with them rather than trying to work around them.
Hi! Post author here. Totally agree with that last statement. That said, I tried to write the post to be geared towards the beginner audience. And I remember when I first started iOS development, UITableView seemed weird. It comes with two delegate objects with separate responsibilities (delegate and dataSource) and is pretty ubiquitous, so you may interact with it right away when first starting iOS development, befo…
Building an Open, Drop-in Replacement for UITableView
11–18 of 18 posts
Re: Building an Open, Drop-in Replacement for UITableView
#12Funny, this was actually really helpful for me as I'm building a dynamic list (or "table" in iOS parlance) for HTML5 in Ionic Framework. Gave me a few ideas on how we could structure the API to handle tons of items efficiently. Great write up!
I suspected most of the concepts could be pretty easily applied to other languages, so I'm especially glad to hear this feedback.
Re: Building an Open, Drop-in Replacement for UITableView
#13This is a great exercise, but please, please don't use your hand-rolled UITableView in your apps.
If UITableView doesn't do what you need, create a UICollectionView. If you find the data source protocol frustrating to use, create a provider object that maps your (array/dictionary/weird-ass data structure) onto the dataSource protocol. (In desktop Mac programming, NSArrayControllers serve this purpose.) Don't re-implement UITableView. The things you could potentially screw up are many, and when some other developer inherits your code and tries to add editing, multiple selection, re-ordering, etc..., they're going to be pissed.
Re: Building an Open, Drop-in Replacement for UITableView
#14Earlier quoted context omitted.
Hi! Post author here. Totally agree with that last statement. That said, I tried to write the post to be geared towards the beginner audience. And I remember when I first started iOS development, UITableView seemed weird. It comes with two delegate objects with separate responsibilities (delegate and dataSource) and is pretty ubiquitous, so you may interact with it right away when first starting iOS development, befo…
I am an iOS beginner. I have not read your post in-depth, I will, but I think it's probably wise to stick to learning UITableView well -- and understanding why I would want to implement something custom -- before avoiding the classes Apple provides. That being said, I understood delegates, categories, and other Objective-C features much better after coding several applications first, reading a ton of open source code…
Re: Building an Open, Drop-in Replacement for UITableView
#15Funny, this was actually really helpful for me as I'm building a dynamic list (or "table" in iOS parlance) for HTML5 in Ionic Framework. Gave me a few ideas on how we could structure the API to handle tons of items efficiently. Great write up!
Re: Building an Open, Drop-in Replacement for UITableView
#16Although, my view of MVC is that the model is just the data (pretty lightweight), the view just draws the things, and the controller handles user actions. So you could remove the view and do testing on the controller. This doesn't seem to be Apple's perspective, so maybe I just haven't figured out their perspective yet.
Re: Building an Open, Drop-in Replacement for UITableView
#17Is it just me, or does it seem like UITableView is a combination of controller and view? The delegate has both controller functionality (selection) and view functionality (cell height). I keep trying to use it as one or the other and you just can't do it. Although, my view of MVC is that the model is just the data (pretty lightweight), the view just draws the things, and the controller handles user actions. So you co…
Re: Building an Open, Drop-in Replacement for UITableView
#18Is it just me, or does it seem like UITableView is a combination of controller and view? The delegate has both controller functionality (selection) and view functionality (cell height). I keep trying to use it as one or the other and you just can't do it. Although, my view of MVC is that the model is just the data (pretty lightweight), the view just draws the things, and the controller handles user actions. So you co…
UIViewController is part of UIKit. UIKit is a framework developed specifically for iOS as a high-level wrapper over OpenGL, for performance reasons as well as making touch screen based interfaces easier to implement.
This is why UIViewController has many view-related hooks in it. For example, the native view lifecycle flow includes a call to the method `viewDidLoad` on UIViewController - a controller method dedicated to view functionality and customization.
That said, the UITableViewDelegate seems to have the standard amount of view and controller commingling that's found throughout the common iOS frameworks, IMO.