You can set the window position to top right corner using:
- (void)setWindowPosition
{
NSPoint pos;
pos.x = [[NSScreen mainScreen] visibleFrame].origin.x + [[NSScreen mainScreen] visibleFrame].size.width - [_window frame].size.width ;
pos.y = [[NSScreen mainScreen] visibleFrame].origin.y + [[NSScreen mainScreen] visibleFrame].size.height - [_window frame].size.height ;
[_window setFrameOrigin : pos];
}
Call this method in your applicationDidFinishLaunching:
, and also register the windowDidResizeNotification
to handle the resize event as:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self setWindowPosition]; //set window pos
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:NSWindowDidResizeNotification object:nil]; //register resize notification
}
Now in your notification handler method, again update the window position.
- (void)handleNotification: (id) sender
{
[self setWindowPosition];
}