Class Delegate Protocol
Delegate protocols should be class-only so they can be weakly referenced
- Identifier:
class_delegate_protocol
- Enabled by default: Yes
- Supports autocorrection: No
- Kind: lint
- Analyzer rule: No
- Minimum Swift compiler version: 5.0.0
- Default configuration:
Key Value severity warning
Non Triggering Examples
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 {}
protocol FooDelegate where Self: BarDelegate {}
protocol FooDelegate where Self: AnyObject {}
protocol FooDelegate where Self: NSObjectProtocol {}
Triggering Examples
↓protocol FooDelegate {}
↓protocol FooDelegate: Bar {}
↓protocol FooDelegate where Self: StringProtocol {}