Swift UITableViewDataSource Cheat Sheet

iOS developers will quickly recognize that there are a set of methods that always tend to get implemented when dealing with UITableViews . The problem I consistently face is remembering that set of methods that belong to the UITableViewDataSource (and UITableViewDelegate ) protocols. I find myself option-clicking the protocol name to remember the method signatures I need, since XCode doesn’t have a way to stub out the methods involved with a protocol (C# developers working in Visual Studio like myself are spoiled!).

I’m sure cheat sheets like this already exist, but I thought, “Why not have one that I can reference from my own blog?”… In fact, I’ve gone ahead and turned the code below into a snippet in XCode, but just in case I ever lose that, I’ve got this post, which stubs out dummy implementations of the three most common UITableViewDataSource protocol methods.

I’d be delighted if it helped my readers as well, so without further ado, here’s my UITableViewDataSource cheat sheet, which should allow you (and me) to copy and paste directly into our UITableViewDataSource class for a quick start: