<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIViewController/targetViewController(forAction:sender:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)targetViewControllerForAction:sender:"
  },
  "title" : "targetViewController(forAction:sender:)"
}
-->

# targetViewController(forAction:sender:)

Returns the view controller that responds to the action.

```
func targetViewController(forAction action: Selector, sender: Any?) -> UIViewController?
```

## Parameters

`action`

The requested action.

`sender`

The object sending the request.

## Return Value

The view controller that handles the specified action or `nil` if no view controller handles the action.

## Discussion

This method returns the current view controller if that view controller overrides the method indicated by the `action` parameter. If the current view controller does not override that method, UIKit walks up the view hierarchy and returns the first view controller that does override it. If no view controller handles the action, this method returns `nil`.

A view controller can selectively respond to an action by returning an appropriate value from its [`canPerformAction(_:withSender:)`](/documentation/UIKit/UIResponder/canPerformAction(_:withSender:)) method.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)