Created
September 16, 2013 01:42
-
-
Save TomLiu/6575851 to your computer and use it in GitHub Desktop.
Get the localized name of a display, given the displ
This file contains hidden or 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
/* Get the localized name of a display, given the display ID. */ | |
-(NSString *)displayNameFromDisplayID:(CGDirectDisplayID)displayID | |
{ | |
NSString *displayProductName = nil; | |
/* Get a CFDictionary with a key for the preferred name of the display. */ | |
NSDictionary *displayInfo = (NSDictionary *)IODisplayCreateInfoDictionary(CGDisplayIOServicePort(displayID), kIODisplayOnlyPreferredName); | |
/* Retrieve the display product name. */ | |
NSDictionary *localizedNames = [displayInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; | |
/* Use the first name. */ | |
if ([localizedNames count] > 0) | |
{ | |
displayProductName = [[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] retain]; | |
} | |
[displayInfo release]; | |
return [displayProductName autorelease]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment