Created
August 7, 2009 14:44
-
-
Save 0xced/163933 to your computer and use it in GitHub Desktop.
Human readable string for a display name (as in the Displays preference pane)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <IOKit/graphics/IOGraphicsLib.h> | |
#import <IOKit/graphics/IOGraphicsTypes.h> | |
NSString* screenNameForDisplay(CGDirectDisplayID displayID) | |
{ | |
NSString *screenName = nil; | |
NSDictionary *deviceInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName); | |
NSDictionary *localizedNames = [deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; | |
if ([localizedNames count] > 0) { | |
screenName = [[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] retain]; | |
} | |
[deviceInfo release]; | |
return [screenName autorelease]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment