Skip to content

Instantly share code, notes, and snippets.

@atr000
Created February 8, 2010 05:16
Show Gist options
  • Save atr000/297896 to your computer and use it in GitHub Desktop.
Save atr000/297896 to your computer and use it in GitHub Desktop.
#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