IOServiceGetMatchingServices not returning graphics model data

I want graphics card details using objective c.
used IOServiceGetMatchingServices api for it, its working fine in Intel processor machine, but not returning model info for M1 machine. here is the code I was using
Code Block
   CFMutableDictionaryRef matchDict = IOServiceMatching("IOPCIDevice");
   
   io_iterator_t iterator;
   
   if (IOServiceGetMatchingServices(kIOMasterPortDefault,matchDict,
                   &iterator) == kIOReturnSuccess)
  {
     io_registry_entry_t regEntry;
     
     while ((regEntry = IOIteratorNext(iterator))) {
       CFMutableDictionaryRef serviceDictionary;
       if (IORegistryEntryCreateCFProperties(regEntry,
                         &serviceDictionary,
                          kCFAllocatorDefault,
                          kNilOptions) != kIOReturnSuccess)
      {
         IOObjectRelease(regEntry);
         continue;
      }
       const void *GPUModel = CFDictionaryGetValue(serviceDictionary, @"model");
       
       if (GPUModel != nil) {
         if (CFGetTypeID(GPUModel) == CFDataGetTypeID()) {
           NSString *modelName = [[NSString alloc] initWithData:
                      (NSData *)GPUModel encoding:NSASCIIStringEncoding];
           
           NSLog(@"GPU Model: %@", modelName);
          [modelName release];
        }
      }
       CFRelease(serviceDictionary);
       IOObjectRelease(regEntry);
    }
     IOObjectRelease(iterator);
  }


I want graphics card details

What do you want this info for?

This matters because different goals have different answers, and I want to make sure I steer you in the right direction.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

I want this Information for Analytics purpose.

In that case I recommend that you run system_profiler with the SPDisplaysDataType and capture its output.

Having said that, there’s not a huge amount of point doing that these days because all current Apple silicon Macs use built-in graphics, so the Mac model implies the graphic info. I could imagine that changing in the future but it’s probably best to cross that bridge if you come to it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

IOServiceGetMatchingServices not returning graphics model data
 
 
Q