• 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: Michael de Haan <email@hidden>
  • Date: Tue, 25 Aug 2009 09:57:55 -0700


On Aug 24, 2009, at 6:02 PM, Graham Cox wrote:


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




G'day Graham,
Thanks for your input. I redesigned the app based on yours and others input. Your and Kyle's design makes much more sense....ie no need for 2 "-applicationWillTerminate:" methods. What I did not fully appreciate, despite reading the notes, (more than once :-) ) was **how** delegation works vs Notification, which these last answers have clarified. All part of learning, I guess.
As always, much appreciated.
_______________________________________________


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


References: 
 >applicationWillTerminate: issue (From: Michael de Haan <email@hidden>)
 >Re: applicationWillTerminate: issue (From: Graham Cox <email@hidden>)

  • Prev by Date: Stop automatic editing of NSTextField
  • Next by Date: Normalize an NSAttributedString
  • Previous by thread: Re: applicationWillTerminate: issue
  • Next by thread: Help needed with ConvertCocoa64 script
  • Index(es):
    • Date
    • Thread