• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSPreferencePane, saving on unselect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPreferencePane, saving on unselect


  • Subject: NSPreferencePane, saving on unselect
  • From: Thomas Harrington <email@hidden>
  • Date: Mon, 25 Nov 2002 12:51:02 -0700

I've got an NSPreferencePane subclass, and I'm starting to wonder if the developer docs have led me down a difficult path with regard to saving changes on unselect.

The basic scheme for saving changes on unselect is as follows:

* If unsaved changes exist, -shouldUnselect displays a sheet asking if the user wants to save; if they do, it returns NSUnselectLater.
* The sheet's callback method calls another method which saves changes; once changes are saved, the pref pane class calls [self replyToShouldUnselect:YES].

Additional complexity comes in from the fact that the prefs are system-wide, and so need to go in /Library/Preferences, leading me to add administrator authentication before changes can be saved. So, following Authentication Services docs w/r/t the use of helper applications, and the NSPreferencePane docs' discussion of NSConnection, saving preferences actually does the following:

* Starts up a helper application
* Vends an object via the default NSConnection
* Helper application retrieves the object and uses it to save prefs.
* If unselect described above is pending, the NSTask exit notification triggers the replyToShouldUnselect:YES mentioned above.

This works just fine if the unselect is triggered by the user clicking over to a different pref pane, but it falls apart if unselect results from the user trying to quit. When that happens, the helper tool is unable to retrieve the vended object (it blocks on -[NSConnection rootProxy]). So, changes don't get saved. But the thing is, the execution path in this case is identical regardless of the reason for the unselect.

So... how to deal with this? The fact that it works when the user's not quitting encourages me to think that I'm not doing anything _completely_ stupid, but what's the deal with the NSConnection when trying to quit?

--
Tom Harrington
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Instantly re-display buttons?
  • Next by Date: Re: Weird coder problem
  • Previous by thread: Re: Weird coder problem
  • Next by thread: fast text
  • Index(es):
    • Date
    • Thread