All Articles

Creating a conforming delegate (UITableViewDelegate) in Swift

This tripped me up for a bit so I hope this helps someone.

I started out with this class, thinking I could just continue on my merry way. This errors in Xcode with: ”class does not conform to NSObjectProtocol

class FastListUITableViewDelegate : UITableViewDelegate { }

Hmm ok, but much there yet, what did I miss? This should definitely be a class; not a protocol (I have methods to implement), not a @class_protocol (wrong use, based on the docs), hmm.

This obviously behaves different than in objective-c. What is inherent in the obj-c version of this that would conform to NSObjectProtocol? NSObject. Every class and C eventually rolls up to this…

This is working so far:

class FastListUITableViewDelegate : NSObject, UITableViewDelegate { }

I’ll report back here if this solution changes

Published 27 Jul 2014

Code. Comics. Crossfit
Tim Broder on Twitter