Learn

Protocols are an important part of the Swift programming language. A protocol is a set of standards that classes, structs, or enums can choose to implement in their own ways. These standards come in the form of properties and functions. Since its inception, Swift has often been referred to as a protocol-oriented language, because protocols were designed to be heavily used while building apps. When a struct conforms to a protocol, it must implement a set of methods or properties, then it gains a set of abilities.

Generics represent another important concept that was introduced in Swift to make functions and protocols more generalizable. Generics allow developers to write functions, classes, structs, and enums that can use different data types. An Array is a generic structure because you can make an Array of Strings, Ints, or any other type.

Both protocols and generics are heavily used in iOS development, so it’s important to understand how they work. Let’s dive in!

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?