NSStringFromClass in Swift is Here!

One of the first things I immediately noticed was missing from Swift was the NSStringFromClass replacement. I like to use the class name for my TableViewCell identifiers, and then just NSStringFromClass to dequeue the cells to avoid spelling issues.

In Swift, I would write an ugly extension to do that as seen in this StackOverflow answer:

Not sure when it happened, but I was extremely to see a more native solution in @aligatr’s blog post!

I tried it out myself just to be sure and it actually works!!

custom BlueTableViewCell

Custom BlueTableViewCell

Super excited I don’t have to use the extension anymore!

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.