Anin T.K
Anin T.K

Reputation: 11

Closing the main window in cocoa?

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 don't want to terminate my application, But would like to just close my window.

Upvotes: 1

Views: 405

Answers (1)

Wevah
Wevah

Reputation: 28242

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).

Upvotes: 2

Related Questions