---
title: "attemptRecovery(fromError:optionIndex:)"
framework: objectivec
role: symbol
role_heading: Instance Method
path: "objectivec/nsobject-swift.class/attemptrecovery(fromerror:optionindex:)"
---

# attemptRecovery(fromError:optionIndex:)

Implemented to attempt a recovery from an error noted in an application-modal dialog.

## Declaration

```swift
func attemptRecovery(fromError error: any Error, optionIndex recoveryOptionIndex: Int) -> Bool
```

## Parameters

- `error`: An doc://com.apple.documentation/documentation/Foundation/NSError object that describes the error, including error recovery options.
- `recoveryOptionIndex`: The index of the user selected recovery option in error’s localized recovery array.

## Return Value

Return Value YES if the error recovery was completed successfully, NO otherwise.

## Discussion

Discussion Invoked when an error alert is been presented to the user in an application-modal dialog, and the user has selected an error recovery option specified by error.
