Accessor called once, fires twice
Accessor called once, fires twice
- Subject: Accessor called once, fires twice
- From: Bill Cheeseman <email@hidden>
- Date: Tue, 19 Feb 2002 17:38:25 -0500
I have a slider with an action method. The action method calls the "set"
accessor for the associated data value. The "set" accessor calls NSLog() to
log the new value to StdIO. That's all very well.
But now I add an associated text field, which is kept synchronized with the
slider by using takeIntValueFrom:. All of a sudden, my "set" accessor logs
the new value TWICE when I click on the slider. EXCEPT when I trace
execution in the debugger.
Oddly, the same thing happens when I click another slider, which is
synchronized with another text field using a DIFFERENT technique (this other
text field responds to a notification from this other "set" accessor and
updates its appearance). This other "set" accessor logs a click on this
other slider TWICE, too. EXCEPT when I trace execution in the debugger.
I can't find any place in my logic where *I* call the "set" accessor twice
(although I recognize that these things can sometimes be hard to see). And
when I set a breakpoint and step through all my code, my "set" accessor only
gets called once and the new value is logged to StdIO only once. But as soon
as I run the application normally, outside the debugger, the "set"
accessor's NSLog() gets called twice. It's awfully hard to debug something
like this when the debugger doesn't reveal the problem.
I am aware that in some circumstances Cocoa looks for and calls "set"
accessors on its own -- for example, when loading nibs, if I understand the
documentation. So, my question: Does Cocoa locate and call "set" accessors
on its own in any other circumstances? Or action methods? What are the
circumstances?
But how could this be the problem, anyway, if a breakpoint on the call to
NSLog() in the "set" accessor only gets hit once when tracing execution in
the debugger? Wouldn't an automatic call to the "set" accessor or the action
method by Cocoa trigger this breakpoint?
(I thought I saw a thread with a similar title recently, but I can't find it
in the archives.)
--
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.