Programmatically get screen size in Mac OS X
I am able to return the screen size using:
- (void) getScreenResolution
NSArray *screenArray = [NSScreen screens];
NSScreen *mainScreen = [NSScreen mainScreen];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
NSScreen *screen = [screenArray objectAtIndex: index];
NSRect screenRect = [screen visibleFrame];
NSString *mString = ((mainScreen == screen) ? @"Main" : @"not-main");
NSLog(@"Screen #%d (%@) Frame: %@", index, mString, NSStringFromRect(screenRect));
Output:
Screen #0 (Main) Frame: 0, 4, 1344, 814
Is there a way to format 1344, 814
to 1344x814
?
Edit:
This works perfectly:
- (NSString*) screenResolution
NSRect screenRect;
NSArray *screenArray = [NSScreen screens];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
NSScreen *screen = [screenArray objectAtIndex: index];
screenRect = [screen visibleFrame];
return [NSString stringWithFormat:@"%.1fx%.1f",screenRect.size.width, screenRect.size.height];
cocoa macos screen resolution
add a comment |
I am able to return the screen size using:
- (void) getScreenResolution
NSArray *screenArray = [NSScreen screens];
NSScreen *mainScreen = [NSScreen mainScreen];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
NSScreen *screen = [screenArray objectAtIndex: index];
NSRect screenRect = [screen visibleFrame];
NSString *mString = ((mainScreen == screen) ? @"Main" : @"not-main");
NSLog(@"Screen #%d (%@) Frame: %@", index, mString, NSStringFromRect(screenRect));
Output:
Screen #0 (Main) Frame: 0, 4, 1344, 814
Is there a way to format 1344, 814
to 1344x814
?
Edit:
This works perfectly:
- (NSString*) screenResolution
NSRect screenRect;
NSArray *screenArray = [NSScreen screens];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
NSScreen *screen = [screenArray objectAtIndex: index];
screenRect = [screen visibleFrame];
return [NSString stringWithFormat:@"%.1fx%.1f",screenRect.size.width, screenRect.size.height];
cocoa macos screen resolution
2
I suggest using fast enumeration instead of indexes for the loop. It will make it both faster and easier to read. Also,visibleFrame
is not the same thing asframe
;visibleFrame
excludes the region occupied by the Dock or (when the Dock is hidden) the show-Dock trigger region, plus the menu bar.
– Peter Hosey
Feb 13 '11 at 6:44
Your code may be much more simple. First of allfor (NSScreen *screen in [NSScreen screens])
.
– Vladimir Prudnikov
Apr 3 '13 at 23:33
Is there a way to get the screen size in real-life measurements? That is, in centimeters or inches?
– adib
Dec 9 '13 at 15:47
You will need to covert pixels to whatever you want. Should be easy enough. Just use the method above to get pixels, then covert.
– WrightsCS
Dec 9 '13 at 17:44
add a comment |
I am able to return the screen size using:
- (void) getScreenResolution
NSArray *screenArray = [NSScreen screens];
NSScreen *mainScreen = [NSScreen mainScreen];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
NSScreen *screen = [screenArray objectAtIndex: index];
NSRect screenRect = [screen visibleFrame];
NSString *mString = ((mainScreen == screen) ? @"Main" : @"not-main");
NSLog(@"Screen #%d (%@) Frame: %@", index, mString, NSStringFromRect(screenRect));
Output:
Screen #0 (Main) Frame: 0, 4, 1344, 814
Is there a way to format 1344, 814
to 1344x814
?
Edit:
This works perfectly:
- (NSString*) screenResolution
NSRect screenRect;
NSArray *screenArray = [NSScreen screens];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
NSScreen *screen = [screenArray objectAtIndex: index];
screenRect = [screen visibleFrame];
return [NSString stringWithFormat:@"%.1fx%.1f",screenRect.size.width, screenRect.size.height];
cocoa macos screen resolution
I am able to return the screen size using:
- (void) getScreenResolution
NSArray *screenArray = [NSScreen screens];
NSScreen *mainScreen = [NSScreen mainScreen];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
NSScreen *screen = [screenArray objectAtIndex: index];
NSRect screenRect = [screen visibleFrame];
NSString *mString = ((mainScreen == screen) ? @"Main" : @"not-main");
NSLog(@"Screen #%d (%@) Frame: %@", index, mString, NSStringFromRect(screenRect));
Output:
Screen #0 (Main) Frame: 0, 4, 1344, 814
Is there a way to format 1344, 814
to 1344x814
?
Edit:
This works perfectly:
- (NSString*) screenResolution
NSRect screenRect;
NSArray *screenArray = [NSScreen screens];
unsigned screenCount = [screenArray count];
unsigned index = 0;
for (index; index < screenCount; index++)
NSScreen *screen = [screenArray objectAtIndex: index];
screenRect = [screen visibleFrame];
return [NSString stringWithFormat:@"%.1fx%.1f",screenRect.size.width, screenRect.size.height];
cocoa macos screen resolution
cocoa macos screen resolution
edited Feb 13 '11 at 6:03
WrightsCS
asked Feb 13 '11 at 5:40
WrightsCSWrightsCS
46k21126173
46k21126173
2
I suggest using fast enumeration instead of indexes for the loop. It will make it both faster and easier to read. Also,visibleFrame
is not the same thing asframe
;visibleFrame
excludes the region occupied by the Dock or (when the Dock is hidden) the show-Dock trigger region, plus the menu bar.
– Peter Hosey
Feb 13 '11 at 6:44
Your code may be much more simple. First of allfor (NSScreen *screen in [NSScreen screens])
.
– Vladimir Prudnikov
Apr 3 '13 at 23:33
Is there a way to get the screen size in real-life measurements? That is, in centimeters or inches?
– adib
Dec 9 '13 at 15:47
You will need to covert pixels to whatever you want. Should be easy enough. Just use the method above to get pixels, then covert.
– WrightsCS
Dec 9 '13 at 17:44
add a comment |
2
I suggest using fast enumeration instead of indexes for the loop. It will make it both faster and easier to read. Also,visibleFrame
is not the same thing asframe
;visibleFrame
excludes the region occupied by the Dock or (when the Dock is hidden) the show-Dock trigger region, plus the menu bar.
– Peter Hosey
Feb 13 '11 at 6:44
Your code may be much more simple. First of allfor (NSScreen *screen in [NSScreen screens])
.
– Vladimir Prudnikov
Apr 3 '13 at 23:33
Is there a way to get the screen size in real-life measurements? That is, in centimeters or inches?
– adib
Dec 9 '13 at 15:47
You will need to covert pixels to whatever you want. Should be easy enough. Just use the method above to get pixels, then covert.
– WrightsCS
Dec 9 '13 at 17:44
2
2
I suggest using fast enumeration instead of indexes for the loop. It will make it both faster and easier to read. Also,
visibleFrame
is not the same thing as frame
; visibleFrame
excludes the region occupied by the Dock or (when the Dock is hidden) the show-Dock trigger region, plus the menu bar.– Peter Hosey
Feb 13 '11 at 6:44
I suggest using fast enumeration instead of indexes for the loop. It will make it both faster and easier to read. Also,
visibleFrame
is not the same thing as frame
; visibleFrame
excludes the region occupied by the Dock or (when the Dock is hidden) the show-Dock trigger region, plus the menu bar.– Peter Hosey
Feb 13 '11 at 6:44
Your code may be much more simple. First of all
for (NSScreen *screen in [NSScreen screens])
.– Vladimir Prudnikov
Apr 3 '13 at 23:33
Your code may be much more simple. First of all
for (NSScreen *screen in [NSScreen screens])
.– Vladimir Prudnikov
Apr 3 '13 at 23:33
Is there a way to get the screen size in real-life measurements? That is, in centimeters or inches?
– adib
Dec 9 '13 at 15:47
Is there a way to get the screen size in real-life measurements? That is, in centimeters or inches?
– adib
Dec 9 '13 at 15:47
You will need to covert pixels to whatever you want. Should be easy enough. Just use the method above to get pixels, then covert.
– WrightsCS
Dec 9 '13 at 17:44
You will need to covert pixels to whatever you want. Should be easy enough. Just use the method above to get pixels, then covert.
– WrightsCS
Dec 9 '13 at 17:44
add a comment |
6 Answers
6
active
oldest
votes
NSLog(@"%fx%f",screenRect.size.width, screenRect.size.height);
2
Sweet,return [NSString stringWithFormat:@"%.0fx%.0f",screenRect.size.width, screenRect.size.height];
worked perfectly to return 1024x768, thanks.
– WrightsCS
Feb 13 '11 at 6:00
add a comment |
Finding the screen size in Mac OS is very simple:
NSRect e = [[NSScreen mainScreen] frame];
H = (int)e.size.height;
W = (int)e.size.width;
Why are you casting the width and height toint
s?
– Peter Hosey
Jul 20 '13 at 19:55
1
@PeterHosey Probably to indicate the height and width areint
s :)
– tomsmeding
Aug 4 '13 at 9:13
@tomsmeding: Members ofNSRect
,NSPoint
, andNSSize
areCGPoint
s.
– Peter Hosey
Aug 4 '13 at 13:55
add a comment |
In Swift 4.0 you can get the screen size of the main screen:
if let screen = NSScreen.main
let rect = screen.frame
let height = rect.size.height
let width = rect.size.width
If you look for the size of the screen with a particular existing window you can get it with:
var window: NSWindow = ... //The Window laying on the desired screen
var screen = window.screen!
var rect = screen.frame
var height = rect.size.height
var width = rect.size.width
add a comment |
For those guy who are looking for a way to get screen resolution:
If you are programming a window based app, you can simply get the resolution from _window.screen.frame.size
add a comment |
edit/update
Swift 4
NSScreen.main?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main?.frame.width // 1,920.0
NSScreen.main?.frame.height // 1,200.0
Swift 3.x
NSScreen.main()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main()?.frame.width // 1,920.0
NSScreen.main()?.frame.height // 1,200.0
Swift 2.x
NSScreen.mainScreen()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.mainScreen()?.frame.width // 1,920.0
NSScreen.mainScreen()?.frame.height // 1,200.0
add a comment |
Swift 3 solution:
NSScreen.main()!.frame
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4982656%2fprogrammatically-get-screen-size-in-mac-os-x%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
NSLog(@"%fx%f",screenRect.size.width, screenRect.size.height);
2
Sweet,return [NSString stringWithFormat:@"%.0fx%.0f",screenRect.size.width, screenRect.size.height];
worked perfectly to return 1024x768, thanks.
– WrightsCS
Feb 13 '11 at 6:00
add a comment |
NSLog(@"%fx%f",screenRect.size.width, screenRect.size.height);
2
Sweet,return [NSString stringWithFormat:@"%.0fx%.0f",screenRect.size.width, screenRect.size.height];
worked perfectly to return 1024x768, thanks.
– WrightsCS
Feb 13 '11 at 6:00
add a comment |
NSLog(@"%fx%f",screenRect.size.width, screenRect.size.height);
NSLog(@"%fx%f",screenRect.size.width, screenRect.size.height);
answered Feb 13 '11 at 5:49
GWWGWW
33.3k69098
33.3k69098
2
Sweet,return [NSString stringWithFormat:@"%.0fx%.0f",screenRect.size.width, screenRect.size.height];
worked perfectly to return 1024x768, thanks.
– WrightsCS
Feb 13 '11 at 6:00
add a comment |
2
Sweet,return [NSString stringWithFormat:@"%.0fx%.0f",screenRect.size.width, screenRect.size.height];
worked perfectly to return 1024x768, thanks.
– WrightsCS
Feb 13 '11 at 6:00
2
2
Sweet,
return [NSString stringWithFormat:@"%.0fx%.0f",screenRect.size.width, screenRect.size.height];
worked perfectly to return 1024x768, thanks.– WrightsCS
Feb 13 '11 at 6:00
Sweet,
return [NSString stringWithFormat:@"%.0fx%.0f",screenRect.size.width, screenRect.size.height];
worked perfectly to return 1024x768, thanks.– WrightsCS
Feb 13 '11 at 6:00
add a comment |
Finding the screen size in Mac OS is very simple:
NSRect e = [[NSScreen mainScreen] frame];
H = (int)e.size.height;
W = (int)e.size.width;
Why are you casting the width and height toint
s?
– Peter Hosey
Jul 20 '13 at 19:55
1
@PeterHosey Probably to indicate the height and width areint
s :)
– tomsmeding
Aug 4 '13 at 9:13
@tomsmeding: Members ofNSRect
,NSPoint
, andNSSize
areCGPoint
s.
– Peter Hosey
Aug 4 '13 at 13:55
add a comment |
Finding the screen size in Mac OS is very simple:
NSRect e = [[NSScreen mainScreen] frame];
H = (int)e.size.height;
W = (int)e.size.width;
Why are you casting the width and height toint
s?
– Peter Hosey
Jul 20 '13 at 19:55
1
@PeterHosey Probably to indicate the height and width areint
s :)
– tomsmeding
Aug 4 '13 at 9:13
@tomsmeding: Members ofNSRect
,NSPoint
, andNSSize
areCGPoint
s.
– Peter Hosey
Aug 4 '13 at 13:55
add a comment |
Finding the screen size in Mac OS is very simple:
NSRect e = [[NSScreen mainScreen] frame];
H = (int)e.size.height;
W = (int)e.size.width;
Finding the screen size in Mac OS is very simple:
NSRect e = [[NSScreen mainScreen] frame];
H = (int)e.size.height;
W = (int)e.size.width;
edited May 19 '13 at 12:09
michaelb958
3,81972433
3,81972433
answered May 19 '13 at 11:48
mamadymamady
18314
18314
Why are you casting the width and height toint
s?
– Peter Hosey
Jul 20 '13 at 19:55
1
@PeterHosey Probably to indicate the height and width areint
s :)
– tomsmeding
Aug 4 '13 at 9:13
@tomsmeding: Members ofNSRect
,NSPoint
, andNSSize
areCGPoint
s.
– Peter Hosey
Aug 4 '13 at 13:55
add a comment |
Why are you casting the width and height toint
s?
– Peter Hosey
Jul 20 '13 at 19:55
1
@PeterHosey Probably to indicate the height and width areint
s :)
– tomsmeding
Aug 4 '13 at 9:13
@tomsmeding: Members ofNSRect
,NSPoint
, andNSSize
areCGPoint
s.
– Peter Hosey
Aug 4 '13 at 13:55
Why are you casting the width and height to
int
s?– Peter Hosey
Jul 20 '13 at 19:55
Why are you casting the width and height to
int
s?– Peter Hosey
Jul 20 '13 at 19:55
1
1
@PeterHosey Probably to indicate the height and width are
int
s :)– tomsmeding
Aug 4 '13 at 9:13
@PeterHosey Probably to indicate the height and width are
int
s :)– tomsmeding
Aug 4 '13 at 9:13
@tomsmeding: Members of
NSRect
, NSPoint
, and NSSize
are CGPoint
s.– Peter Hosey
Aug 4 '13 at 13:55
@tomsmeding: Members of
NSRect
, NSPoint
, and NSSize
are CGPoint
s.– Peter Hosey
Aug 4 '13 at 13:55
add a comment |
In Swift 4.0 you can get the screen size of the main screen:
if let screen = NSScreen.main
let rect = screen.frame
let height = rect.size.height
let width = rect.size.width
If you look for the size of the screen with a particular existing window you can get it with:
var window: NSWindow = ... //The Window laying on the desired screen
var screen = window.screen!
var rect = screen.frame
var height = rect.size.height
var width = rect.size.width
add a comment |
In Swift 4.0 you can get the screen size of the main screen:
if let screen = NSScreen.main
let rect = screen.frame
let height = rect.size.height
let width = rect.size.width
If you look for the size of the screen with a particular existing window you can get it with:
var window: NSWindow = ... //The Window laying on the desired screen
var screen = window.screen!
var rect = screen.frame
var height = rect.size.height
var width = rect.size.width
add a comment |
In Swift 4.0 you can get the screen size of the main screen:
if let screen = NSScreen.main
let rect = screen.frame
let height = rect.size.height
let width = rect.size.width
If you look for the size of the screen with a particular existing window you can get it with:
var window: NSWindow = ... //The Window laying on the desired screen
var screen = window.screen!
var rect = screen.frame
var height = rect.size.height
var width = rect.size.width
In Swift 4.0 you can get the screen size of the main screen:
if let screen = NSScreen.main
let rect = screen.frame
let height = rect.size.height
let width = rect.size.width
If you look for the size of the screen with a particular existing window you can get it with:
var window: NSWindow = ... //The Window laying on the desired screen
var screen = window.screen!
var rect = screen.frame
var height = rect.size.height
var width = rect.size.width
edited Jan 22 '18 at 13:17
Andreas
4591719
4591719
answered Jan 9 '15 at 14:48
j.s.comj.s.com
9491018
9491018
add a comment |
add a comment |
For those guy who are looking for a way to get screen resolution:
If you are programming a window based app, you can simply get the resolution from _window.screen.frame.size
add a comment |
For those guy who are looking for a way to get screen resolution:
If you are programming a window based app, you can simply get the resolution from _window.screen.frame.size
add a comment |
For those guy who are looking for a way to get screen resolution:
If you are programming a window based app, you can simply get the resolution from _window.screen.frame.size
For those guy who are looking for a way to get screen resolution:
If you are programming a window based app, you can simply get the resolution from _window.screen.frame.size
answered Apr 11 '13 at 5:27
JashengmatoJashengmato
7113
7113
add a comment |
add a comment |
edit/update
Swift 4
NSScreen.main?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main?.frame.width // 1,920.0
NSScreen.main?.frame.height // 1,200.0
Swift 3.x
NSScreen.main()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main()?.frame.width // 1,920.0
NSScreen.main()?.frame.height // 1,200.0
Swift 2.x
NSScreen.mainScreen()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.mainScreen()?.frame.width // 1,920.0
NSScreen.mainScreen()?.frame.height // 1,200.0
add a comment |
edit/update
Swift 4
NSScreen.main?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main?.frame.width // 1,920.0
NSScreen.main?.frame.height // 1,200.0
Swift 3.x
NSScreen.main()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main()?.frame.width // 1,920.0
NSScreen.main()?.frame.height // 1,200.0
Swift 2.x
NSScreen.mainScreen()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.mainScreen()?.frame.width // 1,920.0
NSScreen.mainScreen()?.frame.height // 1,200.0
add a comment |
edit/update
Swift 4
NSScreen.main?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main?.frame.width // 1,920.0
NSScreen.main?.frame.height // 1,200.0
Swift 3.x
NSScreen.main()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main()?.frame.width // 1,920.0
NSScreen.main()?.frame.height // 1,200.0
Swift 2.x
NSScreen.mainScreen()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.mainScreen()?.frame.width // 1,920.0
NSScreen.mainScreen()?.frame.height // 1,200.0
edit/update
Swift 4
NSScreen.main?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main?.frame.width // 1,920.0
NSScreen.main?.frame.height // 1,200.0
Swift 3.x
NSScreen.main()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.main()?.frame.width // 1,920.0
NSScreen.main()?.frame.height // 1,200.0
Swift 2.x
NSScreen.mainScreen()?.frame // x 0 y 0 w 1,920 h 1,200
NSScreen.mainScreen()?.frame.width // 1,920.0
NSScreen.mainScreen()?.frame.height // 1,200.0
edited Nov 14 '18 at 19:12
answered Jan 9 '15 at 17:51
Leo DabusLeo Dabus
136k32282353
136k32282353
add a comment |
add a comment |
Swift 3 solution:
NSScreen.main()!.frame
add a comment |
Swift 3 solution:
NSScreen.main()!.frame
add a comment |
Swift 3 solution:
NSScreen.main()!.frame
Swift 3 solution:
NSScreen.main()!.frame
answered May 30 '17 at 22:28
Aron GatesAron Gates
11
11
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4982656%2fprogrammatically-get-screen-size-in-mac-os-x%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
I suggest using fast enumeration instead of indexes for the loop. It will make it both faster and easier to read. Also,
visibleFrame
is not the same thing asframe
;visibleFrame
excludes the region occupied by the Dock or (when the Dock is hidden) the show-Dock trigger region, plus the menu bar.– Peter Hosey
Feb 13 '11 at 6:44
Your code may be much more simple. First of all
for (NSScreen *screen in [NSScreen screens])
.– Vladimir Prudnikov
Apr 3 '13 at 23:33
Is there a way to get the screen size in real-life measurements? That is, in centimeters or inches?
– adib
Dec 9 '13 at 15:47
You will need to covert pixels to whatever you want. Should be easy enough. Just use the method above to get pixels, then covert.
– WrightsCS
Dec 9 '13 at 17:44