Re: Newbie Delegate question - storing preference
Re: Newbie Delegate question - storing preference
- Subject: Re: Newbie Delegate question - storing preference
- From: Ron Medina Ballesteros <email@hidden>
- Date: Sun, 14 Mar 2004 13:07:31 -0800
A delegate is an object that influences the behavior of another object
on how it should act.
I would suggest Aaron Hillegass's Cocoa Programming for an explanation
for a more detailed overview and understanding on delegates.
In your case, you can set your preferences window to have its delegate
the PreferencessController. And in your PreferencessController, you can
implement the delegate method of windowWillClose: and here you have
your code
do the necessary saving and other code such as notifying your other
classes that the preferences has changed.
You'll need to read up on Apple's documentation on delegates and
delegate methods since it is used quite often in
the AppKits.
~r
On Mar 14, 2004, at 9:40 AM, Michael Hanna wrote:
Hello, I have a trivial application that employs a preferences panel
to set and store preferences.
It won't store a property list in the ~/Library/Preferences, but I
know that's because I don't actually do [NSDictionary
standardUserDefaults] setObject: forKey:] anywhere(I have actually set
the Bundle Identifier). I think I do this in PreferencesController.m.
I have two NIB files, MainMenu.nib, and Preferences.nib. MainMenu.nib
relates to MyController object and Preferences.nib relates to
PreferencesController and contains the preferences panel.
So do I need a setPrefs() function in PreferencesController.m? I would
like to perform this function when the user closes the preferences
panel. I know I just can't wire the closing of the panel to the
setPrefs() function in IB, I was told by a Cocoa guru that I need to
delegate this task.
This has left me really confused. What is a delegate, why do I need
one and where and how do I set it. Which nib do I set this delegate
in, MainMenu or Preferences? I'm using 10.3 and xcode by the way.
The project is available below.
Another question, why is it that my DEFAULT_OPACITY_LEVEL is not
reflected in the slider value when the user opens the pref pane?
thanks for any help at all!
Michael
http://www.siddha.ca/~tao/prefster1.1.tar.gz
_______________________________________________
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.
_______________________________________________
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.