I was trying to understand the usage and significance of the typealias marked for code enum declared in the LAError class for the LocalAuthentication framework provided for iOS SDK. I have marked the same in the screenshot attached.

What is the significance and use of the _ErrorType declared inside the LAErro.Code enum?

Reference Image

Any lead on this that which would help me understand would be greatly appreciated.

Corresponding Code Snippet for the image :

@available(iOS 8.0, *)
public struct LAError {

    public init(_nsError: NSError)

    public static var errorDomain: String { get }


    @available(iOS 8.0, *)
    public enum Code : Int {

        public typealias _ErrorType = LAError
1

There are 1 answers

1
Ankit Thakur On

typealias is used to refer anything with another name. e.g.

var ErrorBlock=(ErrorType?) -> Void
typealias ErrorCallback = ErrorBlock

so ErrorCallback and ErrorBlock represent same object.

Here is link, which shows many benefits of typealias. On the summary, here is the list of other examples from the link:

typealias Name = String
typealias Employees = Array<Employee>
typealias GridPoint = (Int, Int)
typealias CompletionHandler = (ErrorType?) -> Void