Where is the variable “code” in SKError defined?

I am seeing examples of code using SKError “code” property or variable. I cannot seem to define any definition for this property. How is xcode / Swift able to access this property? I am using SwiftyStoreKit with this issue. Thanks

Tried looking in the documentation for SKError, nothing there. Tried debugging in xcode, live, cannot understand from xcode where is this thing coming from.

    SwiftyStoreKit.purchaseProduct("X", quantity: 1, atomically: true) { result in
        switch result {
        case .success(let purchase):
            print("Purchase Success: \(purchase.productId)")
            let defaults = UserDefaults.standard
            defaults.set(true, forKey: "Y")
        case .error(let error):
            switch error.code {
            case .unknown: self.Alert("Z")

Just want to know how xcode can access this property.

Leave a Comment