What does @objc do?
Asked on 05/16/2025
1 search
The @objc
attribute in Swift is used to expose Swift code to Objective-C. It allows Swift methods, properties, and classes to be accessible from Objective-C code. This is particularly useful when you are working with legacy Objective-C codebases or when you need to interact with Objective-C frameworks.
When you mark a Swift method or property with @objc
, it becomes available to the Objective-C runtime, which means it can be called from Objective-C code, and it can also be used in places where Objective-C dynamic features are required, such as with selectors or when using certain Cocoa APIs that rely on Objective-C runtime features.
In the context of the WWDC sessions, there is a mention of marking methods as OBC direct
to allow inlining of Objective-C method calls, which helps reduce retain and release traffic. This is related to performance optimizations when working with Objective-C and Swift interoperability.

Analyze heap memory
Dive into the basis for your app’s dynamic memory: the heap! Explore how to use Instruments and Xcode to measure, analyze, and fix common heap issues. We’ll also cover some techniques and best practices for diagnosing transient growth, persistent growth, and leaks in your app.

Explore Swift performance
Discover how Swift balances abstraction and performance. Learn what elements of performance to consider and how the Swift optimizer affects them. Explore the different features of Swift and how they’re implemented to further understand the tradeoffs available that can impact performance.

A Swift Tour: Explore Swift’s features and design
Learn the essential features and design philosophy of the Swift programming language. We’ll explore how to model data, handle errors, use protocols, write concurrent code, and more while building up a Swift package that has a library, an HTTP server, and a command line client. Whether you’re just beginning your Swift journey or have been with us from the start, this talk will help you get the most out of the language.