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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to