跳转至
Type

Protocols

A blueprint of requirements.

Overview

Protocols define a blueprint of requirements. They often provide specific, supplemental functionality to objects which adhere to those requirements. Those requirements can be methods, properties, or even other protocols. Protocols can be used by classes, structures, or enumerations.

One of the most commonly used protocols is View. This protocol has one requirement, a body property.

struct ExampleView: View {
  var body: some View {
      Text("🍌🍌")
  }
}
See the official Apple protocol documentation for more.