Kaji
Kaji

Reputation: 2330

Closing old window when opening a new one in Cocoa

Ok, I have two windows, A and B. When I click a button on Window A, I want it to close and take the user to Window B. makeKeyAndOrderFront does a great job of activating Window B, but how do you get it to then close Window A?

Upvotes: 0

Views: 171

Answers (1)

Peter Hosey
Peter Hosey

Reputation: 96323

Send window A a close or performClose: message (depending on whether you want to emulate the user closing the window, which is the latter, or simply close it immediately and unconditionally).

Note that closing the window may release it; see the releasedWhenClosed property, which has a checkbox in IB and may already be turned on there. You may want to order the window out (as compared to ordering in, such as by ordering front) instead.

Upvotes: 4

Related Questions