<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIFocusDebugger/preferredFocusEnvironments(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIFocusDebugger(cm)preferredFocusEnvironmentsForEnvironment:"
  },
  "title" : "preferredFocusEnvironments(for:)"
}
-->

# preferredFocusEnvironments(for:)

Returns the hierarchy of preferred focus environments for the specified environment object.

```
class func preferredFocusEnvironments(for environment: any UIFocusEnvironment) -> any UIFocusDebuggerOutput
```

## Parameters

`environment`

The object you want to generate a heirarchy of preferred focus environments for. Specify the focus system, view, view controller, or window whose state you want. You can also specify any other object that adopts the [`UIFocusEnvironment`](/documentation/UIKit/UIFocusEnvironment) protocol.

## Return Value

An object the focus debugger uses to store the results to format for display.

## Discussion

Use this method to better understand how the focus system chooses a default focusable item. You call the method from the `lldb` debugger using the following command. In the example, `obj` corresponds to an object that adopts the [`UIFocusEnvironment`](/documentation/UIKit/UIFocusEnvironment) protocol.

```objc
po [UIFocusDebugger preferredFocusEnvironmentsForEnvironment:obj]
```

The method returns the heirarchy of preferred environments for the focus environment object provided.

---

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)