Easily register and dequeue UITableViewCell in Swift

Fernando Martín Ortiz
iOS App Development
1 min readOct 4, 2016

String literals are dangerous, but you have alternatives.

I hate string literals more than anything else. Xcode has no autocompletion for them and they are very insecure because the compiler doesn’t perform any validations on them, so they explode in runtime. And explode a lot, really.

UITableViewCell is an example of that. The typical way of registering and dequeuing cells is a very “stringy” one.

To avoid that situation, I always use this as an alternative for dequeuing:

And this as an alternative for registering:

I hope that this will bring some solutions for you if you hate hardcoding strings as much as me.

--

--