Cocoa Design Patterns

Adopt and interoperate with Cocoa design patterns in your Swift apps.


Common Patterns

Using Key-Value Observing in Swift

Notify objects about changes to the properties of other objects.

Using Delegates to Customize Object Behavior

Respond to events on behalf of a delegator.

Managing a Shared Resource Using a Singleton

Provide access to a shared resource using a single, shared class instance.

About Imported Cocoa Error Parameters

Learn how Cocoa error parameters are converted to Swift throwing methods.

Handling Cocoa Errors in Swift

Throw and catch errors that use Cocoa's error types.

See Also

Language Interoperability

Objective-C and C Code Customization

Apply macros to your Objective-C APIs to customize how they're imported into Swift.

Migrating Your Objective-C Code to Swift

Learn the recommended steps to migrate your code.

Handling Dynamically Typed Methods and Objects in Swift

Cast instances of the Objective-C id type to a specific Swift type.

Using Objective-C Runtime Features in Swift

Use selectors and key paths to interact with dynamic Objective-C APIs.

Imported C and Objective-C APIs

Use native Swift syntax to interoperate with types and functions in C and Objective-C.