How do i get the current size of the screen no matter the resolution change in xcode so that i can adjust my NSRect size to be maximized or take up the screen according to the resolution ? What do I need to add? Would it be something to the NSWindow?
NSRect panelRect = [[self window] frame];
panelRect.size.height = _HEIGHT;
panelRect.size.width = _WIDTH;
panelRect.origin.x = 0;
panelRect.origin.y = 0;
[[self window] setFrame:panelRect display:NO];
Thanks!
Have you tried using
[[NSScreen mainScreen] frame]? If you want to exclude the menubar, you can subtract the menubar height from the NSRect’s height. (It’s around 20 pixels)Edit: If you want your window to be resized from the start, you can put the method above in your controller’s awakeFromNib and use NSWindow’s
setFrame:display:to resize it.