以下方法使用IOKit获取设备序列号,但在iOS 8中会导致应用程序崩溃。有没有人知道这方面的解决方法?我有大量企业拥有的公开可用设备,它们使用企业应用程序,不适用于应用商店提交,并使用序列号来唯一标识设备。
CFTypeRef platformSerialNumber = IORegistryEntryCreateCFProperty(platformExpertDevice, CFSTR("IOPlatformSerialNumber"), kCFAllocatorDefault, 0);
if (CFGetTypeID(platformSerialNumber) == CFStringGetTypeID())
{
serialNumber = [NSString stringWithString:(__bridge NSString*)platformSerialNumber];
CFRelease(platformSerialNumber);
}
IOObjectRelease(platformExpertDevice);
在 CFGetTypeID 上出现 EXC_BAD_ACCESS 错误导致程序崩溃。
控制台记录:* -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL