Re: Query: IBOutlet fails if setter method of same name exists
Re: Query: IBOutlet fails if setter method of same name exists
- Subject: Re: Query: IBOutlet fails if setter method of same name exists
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 13 May 2002 12:58:35 -0400
on 02-05-13 12:27 PM, ruffnex at email@hidden wrote:
>
Consider the following:
>
>
IBOutlet id foobar; // where foobar outlet is connected to foobar object,
>
e.g. CheckBox button
>
>
-(void)setFoobar:(BOOL)boolean; // a method I want to use from within my
>
code
>
>
>
On running the above code, foobar is nil. It's not connected! If the
>
method is renamed, so it doesn't look like a standard setter, than foobar
>
is connected to a real NSButton. Strange behaviour eh?
>
>
Perhaps I've missed something obvious - would appreciate someone shedding
>
some light on this.
Don't do that.
It is an Objective-C (or at least Cocoa) convention that the "set" accessor
for an instance variable is given the same name as the instance variable,
substituting an initial cap for the first letter of the instance variable's
name and adding the prefix "set" (lowercase "s"). The developer tools and
Cocoa make use of this in a number of situations by looking for a set
accessor that follows these naming conventions and using it if found. I
believe this is all done in the key-value coding stuff.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
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.