Skip to content

Latest commit

 

History

History
51 lines (24 loc) · 737 Bytes

class_delegate_protocol.md

File metadata and controls

51 lines (24 loc) · 737 Bytes

Pattern: Invalid class delegate protocol

Issue: -

Description

Delegate protocols should be class-only so they can be weakly referenced.

Examples of correct code:

protocol FooDelegate: class {}


protocol FooDelegate: class, BarDelegate {}


protocol Foo {}


class FooDelegate {}


@objc protocol FooDelegate {}


@objc(MyFooDelegate)
 protocol FooDelegate {}


protocol FooDelegate: BarDelegate {}


protocol FooDelegate: AnyObject {}


protocol FooDelegate: NSObjectProtocol {}

Examples of incorrect code:

protocol FooDelegate {}


protocol FooDelegate: Bar {}

Further Reading