gpt4 book ai didi

cocoa - 如何在 Apple Cocoa 应用程序中获取设备 ID?

转载 作者:行者123 更新时间:2023-12-03 17:37:40 25 4
gpt4 key购买 nike

如何使用 swift 4.2 在 Apple Cocoa 应用程序中获取设备 ID?

最佳答案

您可以使用 IOKit 获取硬件 UUID

func hardwareUUID() -> String?
{
let matchingDict = IOServiceMatching("IOPlatformExpertDevice")
let platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict)
defer{ IOObjectRelease(platformExpert) }

guard platformExpert != 0 else { return nil }
return IORegistryEntryCreateCFProperty(platformExpert, kIOPlatformUUIDKey as CFString, kCFAllocatorDefault, 0).takeRetainedValue() as? String
}

关于cocoa - 如何在 Apple Cocoa 应用程序中获取设备 ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55001600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com