Skip to content

anyobject_protocol

Ian Applebaum edited this page Jun 13, 2020 · 1 revision

AnyObject Protocol

Prefer using AnyObject over class for class-only protocols.

  • Identifier: anyobject_protocol
  • Enabled by default: Disabled
  • Supports autocorrection: Yes
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 4.1.0
  • Default configuration: warning

Non Triggering Examples

protocol SomeProtocol {}
protocol SomeClassOnlyProtocol: AnyObject {}
protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {}
@objc protocol SomeClassOnlyProtocol: AnyObject, SomeInheritedProtocol {}

Triggering Examples

protocol SomeClassOnlyProtocol: class {}
protocol SomeClassOnlyProtocol: class, SomeInheritedProtocol {}
@objc protocol SomeClassOnlyProtocol: class, SomeInheritedProtocol {}
Clone this wiki locally