iOS Developer Library

Developer

Foundation Framework Reference NSErrorRecoveryAttempting Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSErrorRecoveryAttempting

The NSErrorRecoveryAttempting informal protocol provides methods that allow your application to attempt to recover from an error. These methods are invoked when an NSError object is returned that specifies the implementing object as the error recoveryAttempter and the user has selected one of the error’s localized recovery options.

Which method is invoked is dependent on how the error is presented to the user. If the error is presented in a document-modal sheet, attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo: is invoked. If the error is presented in an application-modal dialog, attemptRecoveryFromError:optionIndex: is invoked.

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in iOS 2.0 and later.
  • Implemented to attempt a recovery from an error noted in an document-modal sheet.

    Declaration

    Swift

    func attemptRecoveryFromError(_ error: NSError!, optionIndex recoveryOptionIndex: Int, delegate delegate: AnyObject!, didRecoverSelector didRecoverSelector: Selector, contextInfo contextInfo: UnsafeMutablePointer<Void>)

    Objective-C

    - (void)attemptRecoveryFromError:(NSError *)error optionIndex:(NSUInteger)recoveryOptionIndex delegate:(id)delegate didRecoverSelector:(SEL)didRecoverSelector contextInfo:(void *)contextInfo

    Parameters

    error

    An 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.

    delegate

    An object that is the modal delegate.

    didRecoverSelector

    A selector identifying the method implemented by the modal delegate.

    contextInfo

    Arbitrary data associated with the attempt at error recovery, to be passed to delegate in didRecoverSelector.

    Discussion

    Invoked when an error alert is presented to the user in a document-modal sheet, and the user has selected an error recovery option specified by error. After recovery is attempted, your implementation should send delegate the message specified in didRecoverSelector, passing the provided contextInfo.

    The didRecoverSelector should have the following signature:

    • - (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void *)contextInfo;

    where didRecover is YEStrue if the error recovery attempt was successful; otherwise it is NOfalse.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

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

    Declaration

    Swift

    func attemptRecoveryFromError(_ error: NSError!, optionIndex recoveryOptionIndex: Int) -> Bool

    Objective-C

    - (BOOL)attemptRecoveryFromError:(NSError *)error optionIndex:(NSUInteger)recoveryOptionIndex

    Parameters

    error

    An 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

    YEStrue if the error recovery was completed successfully, NOfalse otherwise.

    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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.