• 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
Re: applicationWillTerminate: issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: applicationWillTerminate: issue


  • Subject: Re: applicationWillTerminate: issue
  • From: Graham Cox <email@hidden>
  • Date: Tue, 25 Aug 2009 11:02:54 +1000


On 25/08/2009, at 10:33 AM, Michael de Haan wrote:

So, 2 quick questions.

1) Is what I am seeing expected behavior or am I doing something wrong.

2) Although not strictly speaking a cocoa question, would better design be to collect all "values/properties" to be saved in one location, thus avoiding the problem I am having?


I'd suggest you should decentralise your preferences handling, or at least, use NSUserDefaults, which centralises them for you. In the bad old days, the classic model was to load all your prefs at start up and save them all at quit, but really it's easier just to get/set each preference at its point of use. You can do that easily using [NSUserDefaults standardUserDefaults]. Then this problem simply goes away as well as keeping your code nice and compartmentalized and even reusable despite having persistent state.

But if for some reason you have to get notified of a terminate, the - applicationWillTerminate: is sent to the application's delegate, so if you have one that implements the method it will be called. Otherwise you have to specifically subscribe to the notification using the NotificationCenter.

--Graham


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: applicationWillTerminate: issue
      • From: Michael de Haan <email@hidden>
References: 
 >applicationWillTerminate: issue (From: Michael de Haan <email@hidden>)

  • Prev by Date: Re: Drawing over a transparent background
  • Next by Date: Re: Syntax Coloring?
  • Previous by thread: Re: applicationWillTerminate: issue
  • Next by thread: Re: applicationWillTerminate: issue
  • Index(es):
    • Date
    • Thread