diff --git a/App Store Receipt Checker/MACAddress.swift b/App Store Receipt Checker/MACAddress.swift index 4e9dfc3..8b8a6ca 100644 --- a/App Store Receipt Checker/MACAddress.swift +++ b/App Store Receipt Checker/MACAddress.swift @@ -13,14 +13,14 @@ import IOKit.network public extension ProcessInfo { - func macAddress() -> [UInt8]? { + var macAddress: [UInt8]? { // create matching services dictionary for IOKit to enumerate — this is some UGLY swift, since we're switching from and then back to `CFDictionary`s guard var matchingDictionary = IOServiceMatching(kIOEthernetInterfaceClass) as? [String : CFTypeRef] else { return nil } matchingDictionary[kIOPropertyMatchKey] = [kIOPrimaryInterface: true] as CFDictionary // there can be only one // create ethernet iterator var ioIterator = io_iterator_t(MACH_PORT_NULL) - guard IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDictionary as CFDictionary, &ioIterator) != 0 else { return nil } + guard IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDictionary as CFDictionary, &ioIterator) == noErr else { return nil } if ioIterator == MACH_PORT_NULL { return nil } // "If NULL is returned, the iteration was successful but found no matching services." defer { IOObjectRelease(ioIterator) } @@ -31,7 +31,7 @@ public extension ProcessInfo { // get that service's parent because the MAC address is there, for reasons var parentService = io_object_t(MACH_PORT_NULL) - guard IORegistryEntryGetParentEntry(firstAndOnlyService, kIOServicePlane, &parentService) != 0 else { return nil } + guard IORegistryEntryGetParentEntry(firstAndOnlyService, kIOServicePlane, &parentService) == noErr else { return nil } defer { IOObjectRelease(parentService) } // finally, get the darn MAC diff --git a/App Store Receipt Checker/Store Receipts/Receipt.swift b/App Store Receipt Checker/Store Receipts/Receipt.swift index 1750563..a702647 100644 --- a/App Store Receipt Checker/Store Receipts/Receipt.swift +++ b/App Store Receipt Checker/Store Receipts/Receipt.swift @@ -246,7 +246,7 @@ private extension Receipt { // MARK: private methods } private func checkReceiptHash() throws { - guard let macAddressBytes = ProcessInfo.processInfo.macAddress() else { throw Errors.cannotGetMacAddress } + guard let macAddressBytes = ProcessInfo.processInfo.macAddress else { throw Errors.cannotGetMacAddress } guard let opaqueValueRawBytes = appReceiptEntries[.opaqueValue]?.rawValue.bytes else { throw Errors.receiptMalformedMissingOpaqueValue } guard let bundleIdentifierRawBytes = appReceiptEntries[.bundleIdentifier]?.rawValue.bytes else { throw Errors.receiptMissingBundleIdentifier }