What’s the difference between a protocol extended from AnyObject and a class-only protocol?

This was answered by an official Swift developer (Slava_Pestov) on the Swift forums. Here is the summary:

  • You should use AnyObject (protocol SomeProtocol: AnyObject).

  • AnyObject and class are equivalent. There is no difference.

  • class will eventually be deprecated.

Leave a Comment