---
title: "preferredFocusEnvironments(for:)"
framework: uikit
role: symbol
role_heading: Type Method
path: "uikit/uifocusdebugger/preferredfocusenvironments(for:)"
---

# preferredFocusEnvironments(for:)

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

## Declaration

```swift
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 doc://com.apple.uikit/documentation/UIKit/UIFocusEnvironment protocol.

## Return Value

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

## Discussion

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 protocol. The method returns the heirarchy of preferred environments for the focus environment object provided.

## See Also

### Getting focus information

- [status()](uikit/uifocusdebugger/status().md)
- [checkFocusability(for:)](uikit/uifocusdebugger/checkfocusability(for:).md)
- [focusGroups(for:)](uikit/uifocusdebugger/focusgroups(for:).md)
- [simulateFocusUpdateRequest(from:)](uikit/uifocusdebugger/simulatefocusupdaterequest(from:).md)
- [UIFocusDebuggerOutput](uikit/uifocusdebuggeroutput.md)
