tags:

views:

55

answers:

1

HI,

How can i close a main window programatically in cocoa?

I want to close my main window in a timer function(nstimer) when a boolean value is set? How can i do that, i dont want to terminate my application, But would like to just close my window.

+1  A: 

Something as simple as:

[NSTimer scheduledTimerWithTimeInterval:delay target:[NSApp mainWindow] selector:@selector(performClose:) userInfo:nil repeats:NO];

should work (where delay is an NSTimeInterval with your desired wait time).

Wevah
Actually I want NSApplicationMain() to return when the UI closes.
Anin T.K
Returning from NSApplicationMain() kind of implies application termination. :)
Wevah