tags:

views:

30

answers:

1

Hello!

In the "mainViewDidLoad" of my NSPreferencePane, I am prompting the user to accept the license and on-user-reject, I would like to close the window. I was hoping that the [NSApplication terminate] would work; and it does! The logic returns from that point in code and we're back at the System Preference Pane window. Just that if the user clicks on my pref icon in the same window again, the application loads again (this time skipping the "mainViewDidLoad") and showing a bare-bone UI (which never got programmatically initiated).

So, I think I can do the following things:

1) Find a way to close the Preference Pane window itself.

I tried to call [NSWindow close], but I get an error when the window closes (This window closed unexpectedly ... ) and every once in a while, the window doesn't close. The error makes sense, since it did close without a proper signal. I'd be curious to know if there's a cleaner exit path.

2) Find a way to realize that my pref pane has been loaded again and show the license.

Using a delegate or notification seems a great way to implement it, but me being a complete noob in mac/cocoa programming, I've got no clue if/how it works. The few docs I went through were a bit tough for my current level of understanding.

Would greatly appreciate any pointers/sample code/suggestions that might drive me in the correct direction.

Thanks!

+1  A: 

You might try implementing the willSelect method instead of mainViewDidLoad.

Peter Hosey
The willSelect method lets me display the license to the user on each select(if required). Thanks for taking the time to answer this!
Abhishek