在項目中引入IOKit.framework來替換AppleAHCIDiskDriver字符串來獲取相應(yīng)的信息,所有的Key 在IOKit/IOKitKeys.h中都有定義
- (void)iotest
{
io_iterator_t iterator;
kern_return_t kr;
io_object_t driver;
CFMutableDictionaryRef matchDictionary = IOServiceMatching("AppleAHCIDiskDriver");
kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matchDictionary, &iterator);
if (kr != kIOReturnSuccess)
{
return;
}
while ((driver = IOIteratorNext(iterator)) != 0)
{
CFMutableDictionaryRef properties = NULL;
kr = IORegistryEntryCreateCFProperties(driver,
&properties,
kCFAllocatorDefault,
kNilOptions);
if (kr != kIOReturnSuccess || properties == NULL)
{
continue;
}
NSLog(@"%@",(__bridge NSDictionary*)properties);
}
}
其中AppleAHCIDiskDriver 這個key可以通過IORegistryExplorer工具看到更多更詳細的Key,而設(shè)備基本信息可以通過IOPlatformExpertDevice獲取.