what is the difference between hitTest(_:with:) and hitTest:withEvent:
Asked on 2025-10-30
1 search
The question about the difference between hitTest(_:with:) and hitTest:withEvent: is not directly covered in the provided context from the WWDC sessions. However, I can provide some general information about these methods based on typical usage in iOS development.
In UIKit, hitTest(_:with:) is a method used to determine which view should receive a touch event. It is called on a view to find the deepest subview that contains a specified point. The method hitTest:withEvent: is an older Objective-C method that serves a similar purpose, allowing you to determine the view that should handle a touch event.
The main difference between these two is the language and API evolution context. hitTest(_:with:) is the Swift version, while hitTest:withEvent: is the Objective-C version. Both are used to manage touch events in a view hierarchy, but the Swift version is more modern and aligns with Swift's language features and conventions.
If you have any questions about the content presented by Apple at WWDC, feel free to ask!

Meet Swift Testing
Introducing Swift Testing: a new package for testing your code using Swift. Explore the building blocks of its powerful new API, discover how it can be applied in common testing workflows, and learn how it relates to XCTest and open source Swift.

What’s new in UIKit
Modernize your app with the latest APIs in UIKit, including enhanced menu bar support, automatic observation tracking, a new UI update method, and improvements to animations. We’ll also cover how you can include SwiftUI scenes in your UIKit app and explore SF Symbols, HDR color pickers, and more.

Platforms State of the Union
Discover the newest advancements on Apple platforms.
