Created
February 8, 2010 05:16
-
-
Save atr000/297896 to your computer and use it in GitHub Desktop.
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
#import <Foundation/Foundation.h> | |
#import <AppKit/AppKit.h> | |
int main (int argc, const char * argv[]) { | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
NSArray *allScreens = [NSScreen screens]; | |
if (allScreens == NULL) { | |
printf("ERROR: No screens found."); | |
return 1; | |
} | |
NSEnumerator *enumerator = [allScreens objectEnumerator]; | |
id object; | |
while (object = [enumerator nextObject]) { | |
NSString *isScreen = [[object deviceDescription] objectForKey:NSDeviceIsScreen]; | |
if ([isScreen isEqualToString:@"YES"] == YES) { | |
int width = [[[object deviceDescription] objectForKey:NSDeviceSize] sizeValue].width; | |
int height = [[[object deviceDescription] objectForKey:NSDeviceSize] sizeValue].height; | |
printf("%d x %d\n", width, height); | |
} | |
} | |
[pool drain]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment