18

is there any way to get the users screen resolution with objective c?

Thanks.

Solution:

int width = [[NSScreen mainScreen] frame].size.width;
int height = [[NSScreen mainScreen] frame].size.height;
dan
  • 5,377
  • 13
  • 39
  • 44

2 Answers2

8

Check out NSScreen.

Nicholas Riley
  • 43,532
  • 6
  • 101
  • 124
  • What about when the scale preference is changed in settings on a mac? [[NSScreen mainScreen] frame].size.width still returns the same thing even if the number of pixels changes – Malachi Holden Jun 17 '20 at 12:10
  • Take a look at https://stackoverflow.com/questions/12589198/how-to-read-the-physical-screen-size-of-osx… – Nicholas Riley Jun 18 '20 at 13:17
1

[UIScreen mainScreen].nativeBounds