Re: Need help moving an NSSlider
Re: Need help moving an NSSlider
- Subject: Re: Need help moving an NSSlider
- From: Fritz Anderson <email@hidden>
- Date: Mon, 9 Feb 2004 10:30:59 -0600
On 9 Feb 2004, at 4:29 AM, Iain Wood wrote:
On 9 Feb 2004, at 02:42, Ryan Bates wrote:
For some reason the NSSlider doesn't like the naming conflict. You
need to rename either the "slider" variable or the "setSlider:"
method. I suggest the method because in normal Cocoa syntax
"setSlider:" may be confused with setting the actual slider instance
variable.
Wel I did that and it worked. Many thanks, no more tearing my hair
out. I don't understand why it works though. Where is the conflict?
There was only one "slider", the IBOutlet, and one "setSlider", the
method.
This is from the documentation of -awakeFromNib, which governs the
process of how the "slider" variable got initialized:
When an Interface Builder archive is loaded into an application, each
custom object from the archive is first initialized with an
initWithCoder: message. Its then more specifically initialized with
the properties that it was configured with using Interface Builder.
This part of the initialization process uses any set<Variable>:
methods that are available (where <Variable> is the name of an
instance variable whose value was set in Interface Builder). If a
set<Variable>: method doesnt exist, the instance variable is searched
for. If it exists, the instance variable is directly set. If the
instance variable doesnt exist, initialization does not occur.
Finally, after all the objects are fully initialized, each receives an
awakeFromNib message.
So when your NIB was loaded, the -setSlider: method was called, in the
(mistaken) belief that it was the method you provided for setting the
"slider" instance variable. That's the name conflict. As your
setSlider: didn't set slider at all, slider was nil throughout the run
of the application, and the slider on the screen never moved.
-- F
_______________________________________________
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.