Re: compiler error related to 'save' method of NSUserDefaultsController
Re: compiler error related to 'save' method of NSUserDefaultsController
- Subject: Re: compiler error related to 'save' method of NSUserDefaultsController
- From: Chris Heimark <email@hidden>
- Date: Sun, 11 Nov 2007 20:31:43 -0500
I see. This particular method is most often associated with a commit/
revert scenario with defaults - as in a panel for defaults and an
associated pair of action buttons.
Thanks very much for your clear explanation. Perhaps if I hang around
here long enough, I "might" gain the equivalent of a week at the Big
Nerd Ranch ;-)
Chris
On Nov 11, 2007, at 8:15 PM, Chris Campbell wrote:
On Nov 11, 2007, at 8:03 PM, Chris Heimark wrote:
That still doesn't tell me why Apple chose to have an ID returned
rather than the standard convention. Is this just an aberration or
is there a specific reason why in this case they chose to return
an ID?
The "convention" in this case is an action method that can be
configured in Interface Builder (set as the target and action for
buttons, menu items, etc). So the method would need to be declared as:
- (IBAction)save:(id)sender;
which is equivalent to:
- (void)save:(id)sender;
Whenever you see a single "(id)sender" argument, think: "Oh, it's
so I can invoke this method by hooking up a target/action in
Interface Builder by control-dragging to this receiver object in
the nib file."
It does make the API a bit odd for invoking the methods
programatically, though. There's always the question of what the
appropriate value for "sender" should be. (Personally, I always use
"nil" because most action methods either don't use the sender
argument at all, or they expect it to be a button or menu item,
which my custom objects certainly aren't.)
- Chris
_______________________________________________
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