docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct NSError

    Information about an error condition including a domain, a domain-specific error code, and application-specific information.

    Implements
    IEquatable<NSError>
    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: UnityEngine.XR.ARKit
    Assembly: Unity.XR.ARKit.dll
    Syntax
    public struct NSError : IEquatable<NSError>
    Remarks

    This is a wrapper for Objective-C's NSError object.

    Properties

    code

    (Read Only) The error code associated with this NSError.

    Declaration
    public long code { get; }
    Property Value
    Type Description
    long
    Remarks

    Error codes are domain-specific. See ToErrorDomain() and domain.

    See Apple's documentation for more information.

    domain

    (Read Only) A string containing the error domain.

    Declaration
    public string domain { get; }
    Property Value
    Type Description
    string
    Remarks

    See Apple's documentation for more information.

    See Also
    ToErrorDomain()

    localizedDescription

    (Read Only) A string containing the localized description of the error.

    Declaration
    public string localizedDescription { get; }
    Property Value
    Type Description
    string
    Remarks

    See Apple's documentation for more information.

    localizedFailureReason

    (Read Only) A string containing the localized explanation of the reason for the error.

    Declaration
    public string localizedFailureReason { get; }
    Property Value
    Type Description
    string
    Remarks

    See Apple's documentation for more information.

    localizedRecoverySuggestion

    (Read Only) A string containing the localized recovery suggestion for the error.

    Declaration
    public string localizedRecoverySuggestion { get; }
    Property Value
    Type Description
    string
    Remarks

    See Apple's documentation for more information.

    Methods

    AsIntPtr()

    Gets the underlying Objective-C pointer.

    Declaration
    public IntPtr AsIntPtr()
    Returns
    Type Description
    IntPtr

    Returns the underlying Objective-C pointer.

    Equals(object)

    Tests for equality.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object to test.

    Returns
    Type Description
    bool

    Returns true if obj is an NSError and is considered equal using Equals(NSError). Returns false otherwise.

    Overrides
    ValueType.Equals(object)

    Equals(NSError)

    Determines whether other is equal to this one as determined by isEqual:.

    Declaration
    public bool Equals(NSError other)
    Parameters
    Type Name Description
    NSError other

    The other NSError to test for equality.

    Returns
    Type Description
    bool

    Returns true if other is considered equal using isEqual:. Returns false otherwise.

    GetHashCode()

    Generates a hash code for this NSError.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    Returns a hash code for this NSError.

    Overrides
    ValueType.GetHashCode()
    Remarks

    The hash code is generated using NSObject's hash property.

    ToErrorDomain()

    The domain as an NSErrorDomain enum.

    Declaration
    public NSErrorDomain ToErrorDomain()
    Returns
    Type Description
    NSErrorDomain

    Returns the NSErrorDomain of this NSError, or Unknown if the error domain could not be determined.

    Remarks

    This method tries to determine the error domain without generating any managed strings. If the error domain is Unknown, you might still be able to get additional information from its string representation (domain).

    ToString()

    Generates a string representation of this NSError.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    Returns a string representation of this NSError.

    Overrides
    ValueType.ToString()
    Remarks

    This method uses NSObject's description property to generate the string.

    Operators

    operator ==(NSError?, NSError?)

    Tests for equality.

    Declaration
    public static bool operator ==(NSError? lhs, NSError? rhs)
    Parameters
    Type Name Description
    NSError? lhs

    The nullable NSError to compare with rhs.

    NSError? rhs

    The nullable NSError to compare with lhs.

    Returns
    Type Description
    bool

    Returns true if any of these conditions are met: - lhs and rhs are both not null and their underlying pointers are equal. - lhs is null and rhs's underlying pointer is null. - rhs is null and lhs's underlying pointer is null. - Both lhs and rhs are null.

     Returns false otherwise.
    
    Remarks

    This equality operator allows you to compare null with an NSError to determine whether its underlying pointer is null. This allows for a more natural comparison with the Objective-C object:

    void TestForNull(NSError error)
    {
        // True if the native NSError object is null.
        if (error == null)
        {
            // Do something with the error
        }
    }

    operator ==(NSError, NSError)

    Tests whether the underlying pointers for two NSError objects are the same.

    Declaration
    public static bool operator ==(NSError lhs, NSError rhs)
    Parameters
    Type Name Description
    NSError lhs

    The NSError to compare with rhs.

    NSError rhs

    The NSError to compare with lhs.

    Returns
    Type Description
    bool

    Returns true if the underlying pointers of lhs and rhs are the same. Returns false otherwise.

    Remarks

    This only tests whether two NSErrors point to the same object in memory. Two different NSErrors could still be considered equal. See Equals(NSError).

    operator !=(NSError?, NSError?)

    Tests for inequality.

    Declaration
    public static bool operator !=(NSError? lhs, NSError? rhs)
    Parameters
    Type Name Description
    NSError? lhs

    The nullable NSError to compare with rhs.

    NSError? rhs

    The nullable NSError to compare with lhs.

    Returns
    Type Description
    bool

    Returns the opposite of operator ==(NSError?, NSError?).

    operator !=(NSError, NSError)

    Tests whether the underlying pointers for two NSError objects are different.

    Declaration
    public static bool operator !=(NSError lhs, NSError rhs)
    Parameters
    Type Name Description
    NSError lhs

    The NSError to compare with rhs.

    NSError rhs

    The NSError to compare with lhs.

    Returns
    Type Description
    bool

    Returns true if the underlying pointers of lhs and rhs are different. Returns false otherwise.

    Remarks

    This only tests whether two NSErrors point to different objects in memory. Two different NSErrors could still be considered equal. See Equals(NSError).

    Implements

    IEquatable<T>

    Extension Methods

    NSErrorExtensions.AsARKitErrorCode(NSError)
    NSErrorExtensions.AsCoreLocationErrorCode(NSError)
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)