0

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
rajkr
  • 51
  • 1
  • 4
  • Please post code as text, not as a picture. Pictures can't be searched, referenced, or copied, and they are harder to post. – rmaddy Sep 22 '18 at 15:35

1 Answers1

0

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
Ankit Thakur
  • 4,739
  • 1
  • 19
  • 35
  • My question is with regards to the significance of the _ErrorType declared in the LAError.Code enum not the usage and benefits of typealias. – rajkr Sep 22 '18 at 17:34