Register the windowDidResizeNotification in your applicationDidFinishLaunching: method to handle the resize event as:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:NSWindowDidResizeNotification object:nil]; //register resize notification
}
Then in the notification handler method, use the code you were previously using to set the window to top right.
- (void)handleNotification: (id) sender
{
//code to set window to top right corner
}
A very recent answer of mine could help you in this: https://stackoverflow.com/a/19677527/1987246